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

Relationships

#532 Copy explicitGlobalArgs before mutation in resolveOrCreateDefinition

Opened by stack72 · 6/2/2026· Shipped 6/2/2026

Problem

In src/libswamp/models/direct_execution.ts:168, the new explicit globalArgs path (added in swamp-club#504 / PR #1491) mutates the caller's object in-place:

Object.assign(explicitGlobalArgs, coerced);

The implicit routing path creates a local {} (line 98) that the function owns, so mutation is safe there. But explicitGlobalArgs is the caller's task.globalArgs reference from the step task data.

Impact

Harmless today because (a) coercion is idempotent and (b) the task is consumed once. But it violates the ownership contract the implicit path follows — if executeModelMethod is ever refactored to re-read task.globalArgs after calling the resolver (e.g. for logging or retry), the coerced values would silently replace the original YAML values.

Fix

Create a local copy before mutating:

const globalArgs = { ...explicitGlobalArgs };
if (modelDef.globalArguments) {
  const coerced = coerceMethodArgs(globalArgs, modelDef.globalArguments);
  Object.assign(globalArgs, coerced);
}
routed = { globalArguments: globalArgs, methodArguments: inputs };

Flagged by the adversarial code review on PR #1491.

02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED+ 1 MOREASSIGNED+ 2 MOREREVIEW+ 3 MOREPR_MERGED+ 1 MORENOTIFICATION_SKIPPED

Shipped

6/2/2026, 9:51:38 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
stack72 assigned stack726/2/2026, 8:40:32 PM

Sign in to post a ripple.