-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix: customised recipe to yaml string to avoid minininjia parsing error #5494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…nja to parse the template
|
.bundle |
1 similar comment
|
.bundle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a utility module to normalize multi-line YAML string formatting to fix issues with MiniJinja template parsing. The changes address a problem where serde_yaml sometimes uses quoted strings with escaped newlines and quotes, which breaks MiniJinja parsing.
Key changes:
- Added new
yaml_format_utils.rsmodule with a function to reformat multi-line string fields in YAML - Added
to_yaml()method to theRecipestruct that applies this reformatting - Updated recipe serialization calls in
recipe_utils.rsto use the newto_yaml()method
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/goose/src/recipe/yaml_format_utils.rs | New utility module that transforms quoted multi-line strings to YAML literal block format and handles unescaping |
| crates/goose/src/recipe/mod.rs | Added to_yaml() method to Recipe struct and module declaration for yaml_format_utils |
| crates/goose-server/src/routes/recipe_utils.rs | Updated two functions to use Recipe's new to_yaml() method instead of direct serde_yaml::to_string() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if let Some(field) = matched_field { | ||
| if let Some((_, raw_val)) = trimmed.split_once(": ") { | ||
| if raw_val.contains("\\n") { |
Copilot
AI
Nov 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The detection logic checks for literal \\n in the string, but this may not correctly identify all multi-line strings. Consider checking for both \\n (single backslash) and \\\\n (double backslash) patterns, or using a more robust method to detect escaped newlines in serialized YAML strings.
| if raw_val.contains("\\n") { | |
| if raw_val.contains("\\n") || raw_val.contains("\\\\n") { |
| reformat_fields_with_multiline_values(&recipe_yaml, &["prompt", "instructions"]); | ||
| Ok(formatted_recipe_yaml) | ||
| } | ||
|
|
Copilot
AI
Nov 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The list of fields to reformat is hardcoded here. Consider making this configurable or deriving it from the Recipe struct to ensure all relevant string fields are handled consistently as the struct evolves.
| reformat_fields_with_multiline_values(&recipe_yaml, &["prompt", "instructions"]); | |
| Ok(formatted_recipe_yaml) | |
| } | |
| reformat_fields_with_multiline_values(&recipe_yaml, Self::multiline_fields()); | |
| Ok(formatted_recipe_yaml) | |
| } | |
| /// Returns the list of Recipe fields that should be reformatted for multiline YAML output. | |
| fn multiline_fields() -> &'static [&'static str] { | |
| &["prompt", "instructions"] | |
| } |
* main: fix: customised recipe to yaml string to avoid minininjia parsing error (#5494) Add pending extension indicator to extension panel (#5493) Add environment subsition for auth blocks (#5439) acp: ToolCallLocations and working cancellation (#5588) feat(providers): add Mistral AI provider (#5009) Listen for ctrl-c during provider request (#5585) Also accept null as description, not just missing (#5589) Document missing recipe param types (#5584) docs: description required for "Add Extension" in cli (#5573) fix: Add schema-aware numeric coercion for MCP tool arguments (#5478) Add uv for uvx in Justfile (#5581) Keep llm logs in place (#5577) bump to 1.12.0 (#5580) automate more of the release process (#5409)
* origin/main: (75 commits) fix: customised recipe to yaml string to avoid minininjia parsing error (#5494) Add pending extension indicator to extension panel (#5493) Add environment subsition for auth blocks (#5439) acp: ToolCallLocations and working cancellation (#5588) feat(providers): add Mistral AI provider (#5009) Listen for ctrl-c during provider request (#5585) Also accept null as description, not just missing (#5589) Document missing recipe param types (#5584) docs: description required for "Add Extension" in cli (#5573) fix: Add schema-aware numeric coercion for MCP tool arguments (#5478) Add uv for uvx in Justfile (#5581) Keep llm logs in place (#5577) bump to 1.12.0 (#5580) automate more of the release process (#5409) add clippy warning for string_slice (#5422) improve linux tray icon support (#5425) feat: log rotation (#5561) use app.isPackaged instead of checking for node env development (#5465) disable RPM build-ID generation to prevent package conflicts (#5563) Add Diagnostics Info to Q&A and Bug Report Templates (#5565) ...
* main: (60 commits) fix: add standard context menu items to prevent empty right-click menu (#5616) Bump openapi in prepare-release (#5611) docs: add access control section to Developer tutorial (#5615) Token state not showing on load, or after message is finished. (#5606) Change the other location too (#5608) feat(ui): bring back quick launcher (#5144) Support platform tools through CLI (#5570) Avoid web double write (#5601) fix: gemini flash -> pro for mcp smoke tests (#5574) Manual compaction test and fix (#5568) fix: tidy up claude cli handling (#5594) Remove jetbrains (#5602) feat(githubcopilot): add support for newer Copilot AI Models (#5603) fix: customised recipe to yaml string to avoid minininjia parsing error (#5494) Add pending extension indicator to extension panel (#5493) Add environment subsition for auth blocks (#5439) acp: ToolCallLocations and working cancellation (#5588) feat(providers): add Mistral AI provider (#5009) Listen for ctrl-c during provider request (#5585) Also accept null as description, not just missing (#5589) ...
* main: (31 commits) Standardize CLI argument flags and update documentation (#5516) Release 1.13.0 fix: move goosehints/AGENTS.md handling to goose, and out of developer extension (#5575) fix: add standard context menu items to prevent empty right-click menu (#5616) Bump openapi in prepare-release (#5611) docs: add access control section to Developer tutorial (#5615) Token state not showing on load, or after message is finished. (#5606) Change the other location too (#5608) feat(ui): bring back quick launcher (#5144) Support platform tools through CLI (#5570) Avoid web double write (#5601) fix: gemini flash -> pro for mcp smoke tests (#5574) Manual compaction test and fix (#5568) fix: tidy up claude cli handling (#5594) Remove jetbrains (#5602) feat(githubcopilot): add support for newer Copilot AI Models (#5603) fix: customised recipe to yaml string to avoid minininjia parsing error (#5494) Add pending extension indicator to extension panel (#5493) Add environment subsition for auth blocks (#5439) acp: ToolCallLocations and working cancellation (#5588) ...
* main: (21 commits) differentiate debug/release in cache key (#5613) Unify subrecipe and subagent execution through shared recipe pipeline (#5082) Standardize CLI argument flags and update documentation (#5516) Release 1.13.0 fix: move goosehints/AGENTS.md handling to goose, and out of developer extension (#5575) fix: add standard context menu items to prevent empty right-click menu (#5616) Bump openapi in prepare-release (#5611) docs: add access control section to Developer tutorial (#5615) Token state not showing on load, or after message is finished. (#5606) Change the other location too (#5608) feat(ui): bring back quick launcher (#5144) Support platform tools through CLI (#5570) Avoid web double write (#5601) fix: gemini flash -> pro for mcp smoke tests (#5574) Manual compaction test and fix (#5568) fix: tidy up claude cli handling (#5594) Remove jetbrains (#5602) feat(githubcopilot): add support for newer Copilot AI Models (#5603) fix: customised recipe to yaml string to avoid minininjia parsing error (#5494) Add pending extension indicator to extension panel (#5493) ...
…or (block#5494) Signed-off-by: fbalicchia <[email protected]>
…or (block#5494) Signed-off-by: Blair Allan <[email protected]>
Summary
This fix is for a recipe with backtick and {{if}} block
Issue
serde_yaml serialization uses internal heuristics to decide between
|and quoted text with escaped\nand\", and the quoted form breaks MiniJinja parsing. It seems that if the texts contains backtick, it tends to use the quoted texts without "|"Example before:
prompt: "Hello \\\"World\\\"\\n{% if user == \\\"admin\\\" %}Welcome{% endif %}"After fix:
Changes
Apply extra format after the yaml serialization to convert the quoted multiline texts to the texts with "|"
Type of Change
Testing
Unit testing and manual testing