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:
- Define a model with globalArguments
{ baseUrl: z.string(), apiKey: z.string() }. - Define a method with
arguments: z.record(z.string(), z.string()). - Create an instance, set baseUrl/apiKey in globalArguments.
- Run
swamp model method run <instance> <method> --input someKey=someValue. - Inside execute(),
argscontains{ 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.
Shipped
Click a lifecycle step above to view its details.