Repository navigation
fix(core): reject trailing content during JSON decoding - #3697
Merged
juruoO-o merged 2 commits intoNov 12, 2026
Merged
Conversation
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
Signed-off-by: fengyue-xve <[email protected]>
juruoO-o
approved these changes
Nov 12, 2026
juruoO-o
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed strict single-root JSON decoding for both overloads, preservation of trailing whitespace and isolation of caller ObjectMapper configuration.
No blocking findings in the reviewed diff. This was a static review of source and tests; local Java/Maven tests were not run.
This was referenced Nov 12, 2026
chickenlj
added a commit
that referenced
this pull request
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The default JacksonJsonCodec accepts the first root JSON value and ignores remaining input. Consequently JsonUtils.isValidJsonObject accepts raw tool-call arguments such as
{"x":1} garbageor{"x":1} {}, and resolveToolCallArgsJson preserves malformed arguments instead of falling back to the structured input. Providers can then reject the tool history.Use a per-call ObjectReader with FAIL_ON_TRAILING_TOKENS for both Class and TypeReference deserialization. Valid trailing JSON whitespace remains accepted. A custom ObjectMapper keeps its own configuration unchanged.
Validation: native Maven regression on the original code reports5failed/1passed. After the fix, native
agentscope-core -amtests for JacksonJsonCodecTrailingContentTest, JacksonJsonCodecTest and JsonUtilsTest pass:44tests,0failures,0skips. Cases cover trailing garbage, a second object, null/number roots after an object, both overloads, actual tool-argument fallback, whitespace and custom mapper configuration. Project Spotless and diff checks pass. Matching English/Chinese tool docs updated. Full repository verification was not run.CI follow-up: Windows failed in unchanged
channel-common/BotLoopGuardTest.activePeersSurviveEvictionOfIdleOnes(expected 1 but was 0), job log. Its900ms sleep can overshoot the1000ms idle/sweep threshold, soallow(active-peer)automatically evicts the idle peer before the later explicit sweep. A standalone run against the unchanged baseline source with a1100ms first sleep reproduces removed=0 while the active peer remains and trackedPeers=1. The JSON module tests pass locally. A rerun attempt currently returnsjob cannot be rerun; the Ubuntu job is still running. This failure is recorded explicitly pending a rerun rather than modifying unrelated channel logic in this PR.