Skip to content

Conversation

@github-actions
Copy link
Contributor

Closes #6232

Summary

Issue #6232 Fix Summary: Recipe slash command doesn't work with single optional parameter

Problem

Recipe slash commands with optional parameters (having requirement: optional and a default value) incorrectly failed with "Recipe requires 1 parameter(s): filename. Provided: 0" when invoked without providing the optional parameter.

Root Cause

In crates/goose/src/recipe/build_recipe/mod.rs, the function build_recipe_from_template_with_positional_params had an early validation check that compared the number of provided params against the total number of recipe params, without considering whether missing params had default values.

Fix

Modified the validation in build_recipe_from_template_with_positional_params to:

  1. Count only required parameters (those without defaults) instead of all parameters
  2. Return only the required parameter keys in the error message when params are missing

The fix changes the check from:

if params.len() < recipe_params.len()

to:

let required_count = recipe_params.iter().filter(|p| p.default.is_none()).count();
if params.len() < required_count

Files Changed

  1. crates/goose/src/recipe/build_recipe/mod.rs - Modified parameter validation logic
  2. crates/goose/src/recipe/build_recipe/tests.rs - Added 4 new tests for positional params with optional parameters

Tests Added

  • test_positional_params_single_optional_with_default_no_args - Verifies single optional param works without args
  • test_positional_params_single_optional_with_default_with_arg - Verifies optional param can still be overridden
  • test_positional_params_required_param_missing_fails - Verifies required params still fail correctly
  • test_positional_params_mixed_required_and_optional - Verifies mixed required/optional params work

Verification

  • All 52 recipe tests pass
  • cargo fmt - clean
  • cargo clippy - no errors

Generated by goose Issue Solver

}
}

mod positional_params_tests {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this test

@katzdave katzdave marked this pull request as ready for review December 22, 2025 23:23
Copilot AI review requested due to automatic review settings December 22, 2025 23:23
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 fixes a bug where recipe slash commands with optional parameters (those having a default value) would incorrectly fail with a "missing parameters" error when invoked without providing the optional parameter. The fix modifies the validation logic in build_recipe_from_template_with_positional_params to distinguish between required and optional parameters.

  • Changed parameter validation to only count parameters without defaults as required
  • Updated error messages to only list required parameters
  • The fix allows optional parameters to be omitted and have their defaults applied via the existing apply_values_to_parameters function

@jamadeo jamadeo merged commit e8247e2 into main Jan 14, 2026
30 of 31 checks passed
@jamadeo jamadeo deleted the goose/issue-6232 branch January 14, 2026 00:06
lifeizhou-ap added a commit that referenced this pull request Jan 14, 2026
* main:
  fix: require auth when running goose on non loopback address (#6478)
  chore(deps): bump hono from 4.11.3 to 4.11.4 in /ui/desktop (#6485)
  feat(cli): graceful fallback for keyring failures (#5808)
  fix: support global .gooseignore and negation patterns (#6157)
  docs: manual config for jetbrains (#6490)
  fix: Recipe slash command doesn't work with single optional parameter (#6235)
  fix(openrouter): Handle Gemini thoughtSignature for tool calls (#6370)
  docs: fix extensions page (#6484)
  Allow customizing the new line keybinding in the CLI (#5956)
  Ask for permission in the CLI (#6475)
  docs: add Ralph Loop tutorial for multi-model iterative development (#6455)
  Remove gitignore fallback from gooseignore docs (#6480)
  fix: clean up result recording for code mode (#6343)
  fix(code_execution): handle model quirks with tool calls (#6352)
  feat(ui): support prefersBorder option for MCP Apps (#6465)
  fixed line breaks (#6459)
  Use Intl.NumberFormat for token formatting in SessionsInsights (#6466)
  feat(ui): format large and small token counts for readability (#6449)
  fix: apply subrecipes when using slash commands (#6460)
ThanhNguyxn pushed a commit to ThanhNguyxn/goose that referenced this pull request Jan 14, 2026
zanesq added a commit that referenced this pull request Jan 14, 2026
…ased

* 'main' of github.com:block/goose:
  fix(code_execution): serialize record_result output as JSON (#6495)
  perf(google): avoid accumulating thoughtSignatures across conversation history (#6462)
  fix(openai): make tool_call arguments optional and fix silent stream termination (#6309)
  fix: Improve error messages for invalid tool calls (#6483)
  fix: require auth when running goose on non loopback address (#6478)
  chore(deps): bump hono from 4.11.3 to 4.11.4 in /ui/desktop (#6485)
  feat(cli): graceful fallback for keyring failures (#5808)
  fix: support global .gooseignore and negation patterns (#6157)
  docs: manual config for jetbrains (#6490)
  fix: Recipe slash command doesn't work with single optional parameter (#6235)
  fix(openrouter): Handle Gemini thoughtSignature for tool calls (#6370)
  docs: fix extensions page (#6484)
  Allow customizing the new line keybinding in the CLI (#5956)
  Ask for permission in the CLI (#6475)
  docs: add Ralph Loop tutorial for multi-model iterative development (#6455)
  Remove gitignore fallback from gooseignore docs (#6480)
  fix: clean up result recording for code mode (#6343)
  fix(code_execution): handle model quirks with tool calls (#6352)
  feat(ui): support prefersBorder option for MCP Apps (#6465)
  fixed line breaks (#6459)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recipe slash command doesn't work with single optional parameter

4 participants