Skip to main content
← Back to list
01Issue
BugShippedSwamp CLI
Assigneesstack72

Relationships

#1364 globalArgs fields leak into method arguments when a method's arguments schema is a bare z.record()

Opened by kitquiet · 7/23/2026· Shipped 7/24/2026

When an extension model method declares its arguments schema as a bare z.record(z.string(), z.string()) (no wrapping z.object with named fields), calling it via swamp model method run <model> <method> --input key=value results in unrelated globalArguments fields being merged into the method's args object alongside the intended --input values.

Repro:

  1. Define a model with globalArguments { baseUrl: z.string(), apiKey: z.string() }.
  2. Define a method with arguments: z.record(z.string(), z.string()).
  3. Create an instance, set baseUrl/apiKey in globalArguments.
  4. Run swamp model method run <instance> <method> --input someKey=someValue.
  5. Inside execute(), args contains { someKey: "someValue", baseUrl: "<the configured baseUrl>" } — baseUrl leaked in even though it was never passed as --input and isn't part of the intended record.

Expected: args should contain only { someKey: "someValue" }.

Workaround found: wrapping the record under a named field (arguments: z.object({ settings: z.record(z.string(), z.string()) })) avoids the leak entirely — only reproduces with a bare top-level z.record() as the whole arguments schema.

Guessing this is because a bare z.record() has no fixed shape to distinguish "declared method args" from other available input context, so something in the CLI's arg-merging logic falls back to including more than intended. Every other method in every extension I've written uses a proper z.object() and never sees this.

02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED+ 1 MOREASSIGNED+ 5 MOREREVIEW+ 4 MOREPR_MERGED+ 1 MORECONTRIBUTOR_NOTIFIED

Shipped

7/24/2026, 7:15:31 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
stack72 assigned stack727/24/2026, 3:44:32 PM
Editable. Press Enter to edit.

stack72 commented 7/24/2026, 7:15:39 PM

Thanks @kitquiet for reporting this! The fix has been merged and a release is on its way. We appreciate your contribution to swamp.

Sign in to post a ripple.