Skip to main content
← Back to list
01Issue
BugClosedSwamp Club
AssigneesNone

CLI method run ignores required arguments without .default()

Opened by swampadmin · 7/8/2025

Description

When running swamp model method run <model> <method> --json -- --arg-name value, required method arguments that don't have a .default() in their Zod schema are silently ignored and not registered as CLI flags. Only arguments with .default() are accessible via -- --flag-name value.

Additionally, even when arguments DO have .default(), passing -- --arg-name value does not override the default — the default is always used.

Steps to Reproduce

  1. Create a model with a method that has a required argument without .default():
arguments: z.object({
  query: z.string().describe("A required query string"),  // no .default()
  limit: z.number().default(100),                         // has .default()
})
  1. Run the method passing both arguments:
swamp model method run my-model my-method --json -- --query "test" --limit 50
  1. Result: --query is silently ignored, --limit uses default value (50 is ignored):
{"error": "Method arguments validation failed: Invalid input: expected string, received undefined at "query""}

Expected Behavior

  • Required arguments without .default() should be registered as mandatory CLI flags
  • Arguments with .default() should accept CLI overrides via -- --arg-name value

Actual Behavior

  • Required arguments without defaults are never parsed from the command line
  • Arguments with defaults always use the default value, ignoring CLI overrides

Workaround

Add .default() to all method arguments. Note that CLI overrides still don't work, so the defaults become the only way to set values (or use instance-level method inputs).

Environment

  • swamp version: 20260304.180533.0-sha.2e4f52b9
  • OS: macOS Darwin 23.6.0

Summary

The CLI flag registration logic in swamp model method run likely only iterates over schema properties that have default values when building the command's option list, and even then doesn't wire up the parsed values to override defaults. The fix would involve:

  1. Registering all schema properties as CLI flags (required ones as mandatory flags)
  2. Wiring parsed CLI values to override Zod defaults before validation
02Bog Flow
OPENTRIAGEDIN PROGRESSCLOSED

Closed

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.