fix(agents): coerce a non-string description in TOML command rendering - #3799
Open
jawwad-ali wants to merge 1 commit into
Open
fix(agents): coerce a non-string description in TOML command rendering#3799jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
CommandRegistrar.render_toml_command passes the raw frontmatter `description`
straight into `_render_basic_toml_string`, which iterates the value and calls
ord() on each character. Frontmatter comes from yaml.safe_load, so description
can be any YAML type:
description='ok string' -> description = "ok string"
description=None -> TypeError: 'NoneType' object is not iterable
description=42 -> TypeError: 'int' object is not iterable
description=True -> TypeError: 'bool' object is not iterable
description=['a','b'] -> description = "ab" <- silently WRONG value
This is a format-branch asymmetry: it is the only renderer reached from
register_commands' format branches that does not normalise description.
render_yaml_command (same class, ~70 lines below) already does exactly
`if not isinstance(description, str): description = str(description) if
description is not None else ""`, render_markdown_command goes through
yaml.dump which handles any type, and TomlIntegration._extract_description
returns "" for a non-str. So only extension/preset commands rendered for the two
TOML agents were affected.
Apply the same coercion the sibling uses. After: None -> "", 42 -> "42",
True -> "True", ['a','b'] -> "['a', 'b']", each still valid parseable TOML.
String descriptions are untouched.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jawwad-ali
force-pushed
the
fix/toml-command-description-coercion
branch
from
July 28, 2026 14:57
dab4e13 to
1d95875
Compare
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
CommandRegistrar.render_toml_commandpasses the raw frontmatterdescriptionstraight into_render_basic_toml_string, which iterates the value and callsord()on each character. Frontmatter comes fromyaml.safe_load, sodescriptioncan be any YAML type:description:with no value is the easy one to hit — plain YAML for an empty field.Format-branch asymmetry
This is the only renderer reached from
register_commands' format branches that does not normalisedescription:render_yaml_command(same class, ~70 lines below)if not isinstance(description, str): description = str(description) if description is not None else ""render_markdown_commandyaml.dump, which handles any typeTomlIntegration._extract_description)""for a non-strrender_toml_commandSo extension/preset commands rendered for the two TOML agents were the only ones affected.
Fix
Apply the same coercion the sibling already uses. After:
Each still parses as valid TOML (asserted via
tomllib.loads). String descriptions are untouched, so existing output is byte-identical.Verification
test_render_toml_command_coerces_non_string_description— 4 parametrized types, asserted throughtomllib.loads: all 4 fail before this change, pass after.test_render_toml_command_*tests (embedded triple quotes, multiline, control characters, backslashes, trailing backslash) all still pass — 11 passed together.uvx ruff@0.15.0 check src testsclean.AI-assisted: authored with Claude Code. I reproduced each failure mode through the real renderer on
main, including the silent['a','b'] -> "ab"mangling, and confirmed the sibling YAML branch already handled all three before mirroring it.