CacheControl / CacheControl/json-rules-engine
PATH is not resolving correctly
- 主要語言
- JavaScript
- 星號
- 3.1k
- 分支
- 507
- PR 合併指標
- 30 天內沒有已合併 PR
描述
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:
```JSON
{
"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:
```javascript
{
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:
```javascript
{
path: '/transfers',
body: { // <-- correct body
amount: '123', // <-- Matching PATH
},
method: 'POST',
}
```
Link for reference: https://github.com/mojaloop/mojaloop-simulator/pull/120/files#r747311386
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
使用提供的規則和 payloads 重現 issue #285,然後查看連結的 Mojaloop 討論,以了解 JSON-PATH 行為的背景。當字串 body 不符合 $.amount 條件,而包含 amount: '123' 的物件 body 符合該條件,並且已在適當的專案測試中加入回歸覆蓋時,修正即完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- javascript
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100