allowUndefinedFacts not working when the facts type are string
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- backend
Research direction
Start by running the provided reproduction with Engine.run, an empty facts object, and allowUndefinedFacts enabled, then trace how the notEqual operator handles the undefined Astring fact versus the numeric Bnumber fact. Done means the option behaves consistently for both fact types and the reproduction produces the documented expected result.
Written by the indexing model from the issue text.
Description
Here's my example, you can reproduce the issue with the code:
const customAttributeRule = {
"name": "allowUndefinedFacts-test",
"attributes": [
{
"name": "Astring",
"type": "string"
},
{
"name": "Bnumber",
"type": "number"
}
],
"decisions": [
{
"conditions": {
"all": [
{
"fact": "Astring",
"operator": "notEqual",
"value": "string"
}
]
},
"event": {
"type": "Astring",
"params": {
"value": "1",
"description": "Astring test"
}
}
},
{
"conditions": {
"all": [
{
"fact": "Bnumber",
"operator": "lessThan",
"value": 5
}
]
},
"event": {
"type": "Bnumber",
"params": {
"value": "1",
"description": "Bnumber test"
}
}
}
]
}
let facts = {}
const engine = new Engine(customAttributeRule.decisions, {allowUndefinedFacts: true});
engine.on('success', event => {
console.log(event)
});
let result = engine .run(facts)
The engine output is
{
type: 'Astring',
params: { value: '1', description: 'Astring test' }
}
However, the allowUndefinedFacts works when then fact type is number
Since the engine treat undefined facts as undefined, so I added another condition that {
"fact": "Astring",
"operator": "notEqual",
"value": "undefined"
}, but it still does not work as expected
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CacheControl/json-rules-engine
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
CacheControl/json-rules-engine#427 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
CacheControl/json-rules-engine#424 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
CacheControl/json-rules-engine#421 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
CacheControl/json-rules-engine#417 · 1 reaction ·
All issues in CacheControl/json-rules-engine
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
palladius/rails8-app-on-gcp#145 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
dotenvx/dotenv-vscode#139 ·
-
test-change-proposal
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
web-platform-tests/interop#1455 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
corsairdev/corsair#1764 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100