Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

PATH is not resolving correctly

Open
#285 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
backend

Research direction

Reproduce issue #285 using the supplied rule and payloads, then review the linked Mojaloop discussion for context on the JSON-PATH behavior. The fix is done when a string body does not satisfy the $.amount condition, while an object body containing amount: '123' does, with regression coverage added in the appropriate project test.

Written by the indexing model from the issue text.

Description

I have seen some strange happenings with regard to how the JSON-PATH is resolving in the rules with "json-rules-engine": "6.1.2".

If you consider the following rule:

{
    "ruleId": 1,
    "description": "Returns an NDC exceeded error response (ML error 4001) from the simulator when transfer value is 123 in any currency",
    "conditions": {
        "all": [
            {
                "fact": "path",
                "operator": "equal",
                "value": "/transfers"
            },
            {
                "fact": "method",
                "operator": "equal",
                "value": "POST"
            },
            {
                "fact": "body",
                "operator": "equal",
                "value": "123",
                "path": "$.amount"
            }
        ]
    },
    "event": {
        "type": "simulateError",
        "params": {
            "statusCode": 500,
            "body": {
                "statusCode": "4001",
                "message": "Payer FSP insufficient liquidity"
            }
        }
    }
}

With the following payload:

{
  path: '/transfers',
  body: '123', // <-- Non-matching PATH
  method: 'POST',
}

The rule will still resolve and fire off the event which I believe is incorrect.

My expectation is that it should only resolve when the payload is as follows:

{
  path: '/transfers',
  body: {      // <-- correct body 
      amount: '123',  // <-- Matching PATH
  },
  method: 'POST',
}

Link for reference: https://github.com/mojaloop/mojaloop-simulator/pull/120/files#r747311386

Dominant language
JavaScript
Stars
3.1k
Forks
507
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from CacheControl/json-rules-engine

All issues in CacheControl/json-rules-engine

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.