Repository navigation
Fix uncaught exception in json node for malformed JSON string with schema + action=str - #5905
Merged
dceejay merged 1 commit intoAug 27, 2026
Conversation
…hema + action=str When the json node's action is "str" (convert to string) and the incoming value is already a string, the node still needs to JSON.parse() it to run schema validation - but unlike every other parse in this file, that call wasn't wrapped in a try/catch. A malformed JSON string in this specific combination (action=str, value already a string, schema set) threw an exception straight out of the "input" handler instead of going through the node's own done(err) completion contract. The runtime's outer safety net (Node.prototype._emitInput) does catch this and log it, so it doesn't crash the process - but it means _complete() is never invoked for that message, skipping the onComplete hook and the "done" metric that every other error path in this node correctly triggers. Verified directly (bypassing the runtime's outer catch) that the unfixed handler throws with doneCalled=false, and the fixed handler correctly calls done(err) with doneCalled=true, for the same malformed input. Wraps the JSON.parse() in that branch in the same try/catch + done(e.message) pattern already used by the three sibling branches in this file. Signed-off-by: Karth <[email protected]>
|
|
Member
|
Thanks, good "catch" :-) |
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.
Summary
In
70-JSON.js, whennode.action === "str"and the incomingmsg[node.property]value is already a string, the node still needs toJSON.parse()it to run schema validation. Every otherJSON.parse()call in this file is wrapped in atry/catchthat callsdone(e.message)on failure - this one branch (lines ~76-90 onmain) is not.Impact
A malformed JSON string reaching this exact combination (
action: "str", value already a string,msg.schemaset) throws straight out of theinputhandler instead of going through the node's owndone(err)completion contract.The runtime's outer safety net (
Node.prototype._emitInput's owntry/catch) does catch this and log it vianode.error(), so it doesn't crash the process or take down other flows - but it means_complete()is never invoked for that message, so theonCompletehook and the"done"metric that every other error path in this node correctly triggers get silently skipped for this one path.Verification
I bypassed the test harness/runtime wrapper and called the node's raw input handler directly with a malformed JSON string in this exact combination:
doneCalled: false, exception message:Expected double-quoted property name in JSON...)done(e.message)correctly (doneCalled: true, nothing thrown)Also ran the full existing
70-JSON_spec.jssuite (27 tests, all passing with the fix) and added a new regression test for this specific combination (malformed JSON string + schema +action: "str"), following the existing test file's conventions.Fix
Wraps the
JSON.parse()call in that one branch in the sametry { ... } catch(e) { done(e.message); }pattern the three sibling branches in this same function already use - no new pattern introduced, just applying the existing correct one consistently.Checklist
main(bug fix)Disclosure: this fix was implemented with AI assistance (Claude), under my direction and review.