Skip to content

b-params参数遇到 . 符号会按照层级去读数据 #1265

Open
chaosblade-io/chaosblade-exec-jvm
#366

Description

@mingyu184

当b-params参数中有 . 符号时会按照层级去读数据,如果值就是user.id则无法读取,应该新增控制参数让用户自己选择
{
"pattern": "or",
"params": [
{
"key": "user.id",
"value": "123",
"mode": "rpc"
}
]
}

Activity

  1. xcaspar commented on Dec 30, 2025

    @xcaspar
    Member

    很好的建议,能否提供一个 PR?

  2. xcaspar commented on Mar 9, 2026

    @xcaspar
    Member

    Thanks for reporting this issue!

    Root Cause

    In the BusinessParamUtil.BusinessParam class, the hasMultiLevelKey() method always returns true when the key contains a dot (.), triggering hierarchical JSON parsing logic. When your RPC parameter name is literally user.id (not a nested structure), the code incorrectly splits the key into user and id, then tries to get JSON from dataGetter.get("user") and look up the id field - resulting in no value being found.

    Solution

    I've added a flat boolean field (default false for backward compatibility) to BusinessParam:

    • flat = false (default): Original behavior, . in key is treated as hierarchical separator
    • flat = true: Key is used as-is, no hierarchical parsing

    Usage Example

    {
      "pattern": "or",
      "params": [
        {
          "key": "user.id",
          "value": "123",
          "mode": "rpc",
          "flat": true
        }
      ]
    }

    With "flat": true, user.id will be queried as a complete parameter name without being split.

    PR

    Fix submitted in chaosblade-exec-jvm: chaosblade-io/chaosblade-exec-jvm#366

    The fix includes:

    • Modified BusinessParamUtil.java to add flat field and logic
    • Added 7 unit tests covering flat mode scenarios
    • All tests pass ✅

    Please review and let me know if you have any questions!

  3. oss-sentinel-ai commented on Jun 4, 2026

    @oss-sentinel-ai
    Contributor

    Issue Evaluation

    Category: type/bug | Status: Confirmed | Severity: Low

    The issue reports that b-params with keys containing a dot (.) like user.id are incorrectly parsed as hierarchical JSON paths instead of literal keys.

    Root Cause: As identified by @xcaspar, the hasMultiLevelKey() method in BusinessParamUtil.BusinessParam always returns true when the key contains a dot, triggering hierarchical parsing. When the actual parameter name is literally user.id (not a nested structure), the code incorrectly splits it.

    Affected Component: chaosblade-exec-jvm - Business parameter parsing for RPC fault injection.

    Fix Direction: Add a configuration flag or escape mechanism (e.g., \. or "user.id") to let users indicate that the dot is literal, not hierarchical. Alternatively, try flat lookup first, then fall back to hierarchical parsing.

    Status: Root cause identified. A PR has been requested from the community.


    Automated evaluation by oss-taishan-ai - ChaosBlade Community Bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions