Skip to content

[BUG] rename_keys processor: json pointers with escaped syntax fail to validate #5121

Closed

Description

@joelmarty

Describe the bug
The escaped syntax for json pointers define how to build json pointers for fields that include special characters.

However, the isValidKey() method in JacksonEventKey only checks the basic character set and keys defined with the escaped syntax are rejected.

To Reproduce
Steps to reproduce the behavior:

  1. Create a pipeline with a rename_keys processor using an escaped syntax:
my-file-pipeline:
  source:
    file:
      path: run/data/events.jsonl
      record_type: event
      format: json
  sink:
    - file:
        path: "run/data/result.jsonl"
  processor:
    - rename_keys:
        entries:
          - from_key: host
            to_key: '"cs(host)"'
  1. Run data-prepper
  2. data-prepper cannot start with the error:

2024-10-28T16:35:39,367 [main] ERROR org.opensearch.dataprepper.core.validation.LoggingPluginErrorsHandler - 1. rp-pipeline-file.processor.rename_keys: caused by: Parameter "entries.null.to_key" for plugin "rename_keys" is invalid: key "cs(host)" must contain only alphanumeric chars with .-_@/ and must follow JsonPointer (ie. 'field/to/key')

Expected behavior
The to_key argument "cs(host)" should be accepted as it conforms to the documented syntax.

Screenshots
N/A

Environment (please complete the following information):

  • OS: macOs
  • Version 14.5

Additional context
N/A

Activity

  1. dlvenable commented on Oct 29, 2024

    @dlvenable
    Member

    @joelmarty , Do you want to produce key names with parenthesis in them?

  2. dlvenable commented on Oct 29, 2024

    @dlvenable
    Member

    Perhaps we can make use of escape sequences to allow parenthesis. Right now, our validation just looks for the characters themselves. But, we do not allow them to be escaped.

    We have some related work in #5111.

  3. joelmarty commented on Oct 30, 2024

    @joelmarty
    ContributorAuthor

    @dlvenable yes, I am trying to produce field names compatible with w3c's extended log file format, that uses the format prefix(header) to designate headers sent in the request or the response. For instance, cs(user-agent) is the field for the user-agent header sent in the request.

  4. added
    help wantedExtra attention is needed
    and removed
    questionFurther information is requested
    on Mar 11, 2025
  5. dlvenable commented on Mar 11, 2025

    @dlvenable
    Member

    @joelmarty , I don't think we are working this, but if you'd like to work this, we can help with guiding you on what to change.

  6. Utkarsh-Aga commented on Jul 9, 2025

    @Utkarsh-Aga
    Contributor

    Hello @dlvenable
    If no one is working on this yet, I can work on this.

  7. dlvenable commented on Jul 16, 2025

    @dlvenable
    Member

    This does work in OpenSearch, so we should support this natively in Data Prepper:

    PUT test_index
    POST test_index/_doc
    {
      "value" : "abc",
      "cs(host)" : "127.0.0.1"
    }
    GET test_index/_search
    {
      "query": {
        "match_all": {}
      }
    }
    

    results in:

    {
      "took": 1,
      "timed_out": false,
      "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
      },
      "hits": {
        "total": {
          "value": 1,
          "relation": "eq"
        },
        "max_score": 1,
        "hits": [
          {
            "_index": "test_index",
            "_id": "cXFOFJgBIv8y3Y3ZCjb8",
            "_score": 1,
            "_source": {
              "value": "abc",
              "cs(host)": "127.0.0.1"
            }
          }
        ]
      }
    }
    
  8. dlvenable commented on Jul 16, 2025

    @dlvenable
    Member

    @Utkarsh-Aga , if you can work this, that would be great.

    We need to include parenthesis here:

    if (!(c >= 48 && c <= 57
    || c >= 65 && c <= 90
    || c >= 97 && c <= 122
    || c == '.'
    || c == '-'
    || c == '_'
    || c == '~'
    || c == '@'
    || c == '/'
    || c == '['
    || c == ']'
    )) {

    and here:

    private static final Pattern INVALID_KEY_CHARS_PATTERN =
    Pattern.compile("[^A-Za-z0-9._~@/\\[\\]-]");

    We would definitely want some unit tests as well.

  9. Utkarsh-Aga commented on Jul 17, 2025

    @Utkarsh-Aga
    Contributor

    Okay Sure, Would work on it.
    Thank you

  10. added this to the v2.16 milestone on Apr 21, 2026
  11. dlvenable commented on Apr 21, 2026

    @dlvenable
    Member

    Resolved by #6233 .

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

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions