Skip to content

removed the line number in the error message#6736

Merged
lifeizhou-ap merged 1 commit intomainfrom
lifei/better-recipe-validate-error-message
Jan 27, 2026
Merged

removed the line number in the error message#6736
lifeizhou-ap merged 1 commit intomainfrom
lifei/better-recipe-validate-error-message

Conversation

@lifeizhou-ap
Copy link
Collaborator

@lifeizhou-ap lifeizhou-ap commented Jan 27, 2026

Summary

Improved recipe error handling and validation to produce friendlier error messages (without line/column numbers)

Why
When user saves or imports recipe, the goose server will deserialise the recipe in the request level and it will show the error of "missing field title: line1 column1". Sometimes the recipe is not provided via a file to call these end points, it could be a deeplink or serialised UI form data, so it does not make sense to include the line number, column number. Even with a recipe file in CLI, since it already specifies the field name in the error message, we don't need the line number, column number.

What

  • Removed the line number related from error message via parsing (looking for at line). I was trying to find a better approach like using custom error message but seems the solution is creating a custom deserializer with all the validation. With the custom deserializer, we have to duplicate the logic of required field, type of data in default serde behaviour for each field. Therefore, I chose to use the parsing error message approach which is simpler

  • Renamed the internal template name from current_template to recipe_template so that it makes a bit more sense in the minininjia error message.

Type of Change

  • Feature
  • Bug fix
  • Refactor / Code quality
  • Performance improvement
  • Documentation
  • Tests
  • Security fix
  • Build / Release
  • Other (specify below)

AI Assistance

  • This PR was created or reviewed with AI assistance

Testing

Unit test and manual test

Related Issues

Relates to #ISSUE_ID
Discussion: LINK (if any)

Copilot AI review requested due to automatic review settings January 27, 2026 11:49
Copy link
Contributor

Copilot AI left a 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 refines recipe error handling and validation to produce friendlier error messages (without line/column numbers) and adds validation coverage for retry configuration.

Changes:

  • Centralizes retry configuration validation in validate_recipe_template_from_content and adds tests for RetryConfig::validate plus a template build test for invalid retry configs.
  • Introduces strip_error_location to trim serde/YAML/JSON error messages and applies it in Recipe::from_content and deserialize_save_recipe_request, updating tests to assert the new error strings.
  • Adjusts MiniJinja’s internal template name (CURRENT_TEMPLATE_NAME) to "recipe_template" for clarity and imports/typing in server routes to use the new helper.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/goose/src/recipe/validate_recipe.rs Adds validate_retry_config and calls it from validate_recipe_template_from_content so invalid retry configs are caught during recipe/template validation.
crates/goose/src/recipe/template_recipe.rs Renames the internal template name constant to "recipe_template" while keeping all usages consistent.
crates/goose/src/recipe/mod.rs Introduces strip_error_location and uses it to remove serde location info from Recipe::from_content errors; removes inline retry validation from from_content; adds tests asserting the new error message format.
crates/goose/src/recipe/build_recipe/tests.rs Adds a test ensuring build_recipe_from_template surfaces invalid retry configs as a TemplateRendering error with a clear message.
crates/goose/src/agents/types.rs Adds unit tests covering RetryConfig::validate success and failure cases (zero retries and zero timeouts).
crates/goose-server/src/routes/recipe.rs Imports strip_error_location, narrows the type annotation for request in save_recipe, and applies strip_error_location when formatting SaveRecipeRequest deserialization errors to hide line/column details.

@lifeizhou-ap lifeizhou-ap merged commit beca05f into main Jan 27, 2026
21 of 22 checks passed
@lifeizhou-ap lifeizhou-ap deleted the lifei/better-recipe-validate-error-message branch January 27, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants