Skip to content

fix: replace regex in findValOfKey with JSON parsing - #65

Open
mdryaaan wants to merge 3 commits into
urunc-dev:mainfrom
mdryaaan:fix/find-val-of-key-json-parsing
Open

mdryaaan wants to merge 3 commits into
urunc-dev:mainfrom
mdryaaan:fix/find-val-of-key-json-parsing

Conversation

@mdryaaan

Copy link
Copy Markdown
Contributor

Description

findValOfKey in tests/e2e/common.go extracted JSON values using a regex ([^,;\\]}]*) that stops at the first comma, semicomp, ], or }. This silently returns truncated data for any JSON value containing those characters — string values with commas are truncated, and nested object values are mangled beyond use.

This replaces the regex with encoding/json unmarshalling and a recursiv key search (searchJSONKey), with jsonValToString for type-safe value serialization back to string.

Related issues

How was this tested?

TestFindValOfKey in tests/e2e/common_test.go was added with 5 subtests.

Before the fix, two fail:

Screenshot 2026-05-15 214758

After the fix, all 5 pass:

Screenshot 2026-05-15 222151

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

cmainas and others added 3 commits May 8, 2026 12:24
PR: urunc-dev#58
Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
Reviewed-by: Panagiotis Mavrikos <pmavrikos@nubificus.co.uk>
Approved-by: Panagiotis Mavrikos <pmavrikos@nubificus.co.uk>
PR: urunc-dev#59
Signed-off-by: char ma <test@mail.com>
Reviewed-by: Charalampos Mainas <cmainas@nubificus.co.uk>
Approved-by: Charalampos Mainas <cmainas@nubificus.co.uk>
Signed-off-by: Md Raiyan <alikhurshid842001@gmail.com>
@mdryaaan

Copy link
Copy Markdown
Contributor Author

Hi @cmainas Could you please review this, whenever you get chance.
Thanks

@cmainas

cmainas commented May 18, 2026

Copy link
Copy Markdown
Contributor

Hello @mdryaan this is not the repo of urunc..

@cmainas
cmainas force-pushed the main branch 2 times, most recently from 5bae1ca to 27f3d06 Compare September 16, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

findValOfKey regex silently truncates JSON values

3 participants