Repository navigation
Refuse catalog YAML that safe loading rejects as an invalid document - #714
Merged
TonsOfFun merged 1 commit intoNov 17, 2026
Merged
Conversation
Catalog.parse rescued only Psych::SyntaxError. YAML.safe_load refuses a
tag naming a class outside the permitted list (Psych::DisallowedClass) and
an alias to an undefined anchor (Psych::BadAlias) with errors that are not
syntax errors, so a document such as `--- !ruby/object:Object {}` escaped
ScenarioCatalogImport as a 500 from the catalog import and preview
endpoints, and as an internal error from the catalogs_import and
catalogs_preview MCP tools.
The rescue is now Psych::Exception, their common parent, as ScenarioParser
and the CLI credentials reader already do, so these documents get the
same "the catalog is not valid YAML" 422 as a syntax error. The permitted
classes and aliases are unchanged.
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.
What this does
Catalog.parseturned onlyPsych::SyntaxErrorintoCatalog::InvalidDocument.YAML.safe_loadrefuses two other things with siblingPsych::Exceptionsubclasses: a tag naming a class outside the permitted list (Psych::DisallowedClass, for example--- !ruby/object:Object {}), and an alias to an anchor the document never defines (Psych::BadAlias). Every caller rescues onlyInvalidDocument, so these documents escaped:catalogs_importandcatalogs_previewMCP tools, as an internal error rather than a tool error,The rescue is now
Psych::Exception, their common parent.ScenarioParser, the CLI credentials reader and the sandbox config readers already use it. These documents now get the same 422 "the catalog is not valid YAML: ..." as a syntax error. What safe loading permits (Symbol, aliases) is unchanged, andCatalog.load(trusted files, rake tasks) is untouched.Tests:
test/evals/catalog_test.rb: a disallowed class at the root and nested, and an undefined alias, are each refused asInvalidDocumentwith the reason. Symbols and anchors/aliases still parse.actionagent/test/scenario_catalogs_api_test.rb: import and preview of!ruby/object:Objectanswer 422 and create nothing.actionagent/test/mcp_dashboard_tools_test.rb:catalogs_importandcatalogs_previewanswer withisError: true.Psych::DisallowedClassraised from the parser and the controller, and no tool error from MCP.Type of change
Scope check
Related issue
None filed.
Quality check
bin/rubocopon the changed files)CliContractTest(rack-sessionundefined method 'id' for Hash), which fail identically on an untouchedmainin this environmentOwnership
API changes