data-prepper icon indicating copy to clipboard operation
data-prepper copied to clipboard

[BUG] Current support for setting JSON pointer values in Event

Open graytaylor0 opened this issue 6 months ago • 1 comments

Describe the bug The JacksonEvent put operation does not honor JSON pointer operations

To Reproduce Steps to reproduce the behavior:

  1. Configure an add_entries processor
processor:
    - add_entries:
        entries:
          - key: z~1y
            value: "some_value"
  1. Observe the literal key z~1y instead of literal key z/y

Expected behavior Create a literal, but not nested, key for z~1y

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: [e.g. Ubuntu 20.04 LTS]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

graytaylor0 avatar Oct 08 '25 15:10 graytaylor0

Hey @graytaylor0! 👋

I'd love to take a crack at this one if it's still available!

Looking at the setNode method in JacksonEvent.java, when we do a put operation, the leafKey goes straight into ((ObjectNode) parentNode).set(leafKey, valueNode) without any JSON Pointer unescaping. So if someone tries put("z~1y", value), it creates a field literally called z~1y instead of z/y.

This seems similar to what was described in #5953 for the delete operation. The fix would involve unescaping the JSON Pointer notation (like ~1/) before we set the value on the ObjectNode.

I'd also make sure to add tests covering keys with slashes, tildes, and other special characters to prevent this from popping up again.

Sound good? Let me know if there's anything specific I should keep in mind!

gmartincor avatar Nov 02 '25 05:11 gmartincor