Repository navigation
guardrails runner: report deeply nested configs as exit 2 instead of crashing (fixes #400) - #410
Open
vanshwadhwa24 wants to merge 2 commits into
Open
vanshwadhwa24 wants to merge 2 commits into
vanshwadhwa24 wants to merge 2 commits into
Conversation
…crashing json.loads raises RecursionError on deeply nested configuration, which escaped the error handler in main() and produced an uncaught traceback with exit code 1, breaking the documented contract (exit 2 and a JSON report on stdout for parsing failures). Catch RecursionError alongside the existing exceptions.
Cover the deeply nested config contract (exit 2 with a JSON report, no traceback) and the shipped chatbot profile passing with exit 0. The deeply nested case fails on the unpatched runner.
This branch has not been deployed
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.
Problem and scope
guardrails_runner.py checkcrashes with an uncaughtRecursionError(traceback, exit code 1) on deeply nested configuration JSON, breaking the documented contract: exit 2 for file/schema parsing failures, always a JSON report on stdout (reported in #400). A CI gate cannot distinguish a crashed parser from a failed validation. Scope is the runner's error handling plus regression tests.What changed
guardrails_runner.py:main()now catchesRecursionErroralongside the existingOSError, ValueError, TypeError, so a deeply nested config produces the standard JSON error report on stdout and exit code 2. In my reproduction theRecursionErroris raised byjson.loadsduring parsing; the same handler would also catch one raised later in the command path, though I have only reproduced the parsing case.test_guardrails_runner.pynext to the runner with two regression tests: a 10,000-level config (60,001 bytes, under the 1 MB limit) must exit 2 with a parseable JSON report and no traceback on stderr, and the shippedguardrails_chatbot.jsonprofile must still pass with exit 0.Verification
python -m black --config .github/quality/pyproject.toml --check .github/quality/testspython -m flake8 --config .github/quality/.flake8 .github/quality/testspython -m pytest -c .github/quality/pyproject.toml .github/quality/tests(924 passed; this suite does not discover the new test file)Changed-file checks: the new
test_guardrails_runner.pypassesblack --checkandflake8with the repo configs. The modifiedguardrails_runner.pyis a one-line change to an existing statement, left in the file's current style; note CI currently lints only.github/quality/tests, so neitherskills/file is covered by CI lint (#402 tracks that gap).Direct test runs (from
skills/unvibecode_gaurdrails_implemenataion_pack/Pre-configured_gaurdrails_programs/,python -m pytest test_guardrails_runner.py -q):1 failed, 1 passed- the deeply nested config (60,001 bytes, 10,000 levels) crashes withRecursionError: maximum recursion depth exceeded while decoding a JSON object, traceback on stderr, exit code 1, no stdout report.2 passed- the same config prints{"configuration_valid": false, "runtime_verified": false, "error": "Invalid configuration or file operation; check the schema and path."}on stdout and exits 2.Disclosure: this change was prepared with AI assistance (code edit and test runs); the before/after results above are the actual outputs from the local runs.
Fixes #400