Right side of Rule condition Fact comparison does not appear in Condition result

Open
#310 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start by reproducing the shown Rule condition with two Fact comparisons and trace how the Condition result is assembled. The change is done when the result exposes the resolved values for both the left and right Facts, with coverage for this comparison case.

Written by the indexing model from the issue text.

Description

If I have a Rule condition such as:

  {
    fact: 'related-study-design',
    params,
    path: '$.id',
    operator: 'equal',
    value: {
      fact: "active-study-design",
      params,
      path: '$.id'
    }
  }

Where I'm comparing the values of two Facts, the factResult value does not appear to show the actual values of both Facts in the Condition results:

{
  fact: "related-study-design",
  params: {
    id: "study-designs-EFKeEO9bFQrWCr7Nhr5u3/RmPP1lqIkrkPMa5D_KRw6",
  },
  path: "$.id",
  operator: "equal",
  value: {
    fact: "active-study-design",
    params: {
      id: "study-designs-EFKeEO9bFQrWCr7Nhr5u3/RmPP1lqIkrkPMa5D_KRw6",
    },
    path: "$.id",
  },
  factResult: "study-designs-EFKeEO9bFQrWCr7Nhr5u3/RmPP1lqIkrkPMa5D_KRw6",
  result: false,
}

As you can see, the value of "active-study-design" Fact is not available in the results. Is there any way to get both sides of this comparison in the condition results? I would have expected another factResult under value like this:

{
  fact: "related-study-design",
  params: {
    id: "study-designs-EFKeEO9bFQrWCr7Nhr5u3/RmPP1lqIkrkPMa5D_KRw6",
  },
  path: "$.id",
  operator: "equal",
  value: {
    fact: "active-study-design",
    params: {
      id: "study-designs-EFKeEO9bFQrWCr7Nhr5u3/RmPP1lqIkrkPMa5D_KRw6",
    },
    path: "$.id",
    factResult: "study-designs-EFKeEO9bFQrWCr7Nhr5u3/n4Q2kVkVbGVzTig9ZTF0f",
  },
  factResult: "study-designs-EFKeEO9bFQrWCr7Nhr5u3/RmPP1lqIkrkPMa5D_KRw6",
  result: false,
}
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.