fix: wrap validateRuntimeState in try-catch to prevent pipeline crash#132
Open
pzysvip99999 wants to merge 1 commit intoNarcooo:masterfrom
Open
fix: wrap validateRuntimeState in try-catch to prevent pipeline crash#132pzysvip99999 wants to merge 1 commit intoNarcooo:masterfrom
pzysvip99999 wants to merge 1 commit intoNarcooo:masterfrom
Conversation
…ors from crashing the pipeline The state validator was throwing an uncaught exception when the LLM output contains invalid JSON characters (e.g. control chars, unescaped sequences), causing the entire write pipeline to crash with 'State validator returned invalid JSON'. This wraps the entire function in a try-catch so that any such errors are returned as a validation issue rather than crashing.
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.
Fix: prevent state validator crash from invalid JSON parse errors
Problem
When the LLM outputs JSON containing invalid characters (e.g. control chars like \x00, malformed escape sequences), the Zod schema parse throws a non-ZodError exception. Since
validateRuntimeState()was not wrapped in a try-catch, this uncaught exception crashed the entire write pipeline with:Fix
Wrap the entire
validateRuntimeStatefunction body in a try-catch. Any uncaught errors (JSON.parse failures, schema.parse throws from non-Zod sources) are now returned as a validation issue with codevalidator_crashrather than crashing the process.Testing