-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Description
Extension model methods that call context.writeResource() succeed but produce empty dataArtifacts: [] in the output. This affects ALL extension models using the default raw execution driver.
Steps to Reproduce
- Create any extension model with a method that calls
context.writeResource() - Run the method:
swamp model method run <name> <method> --json - Observe
"dataArtifacts": []in the output despite the method succeeding
Example with the @tubearchivist/api extension:
swamp model method run tubearchivist stats --json
# Returns: "dataArtifacts": [], "status": "succeeded"The API call succeeds, writeResource is called, but no data artifacts are produced.
Root Cause
In src/domain/drivers/raw_execution_driver.ts (lines 89-147):
createResourceWriter()returns{ writeResource, getHandles }but onlywriteResourceis destructured —getHandlesis ignored (line 89-91)writeResourceis injected into the context and correctly persists data to disk- After method execution, the driver reads
result.dataHandlesfrom the method's return value (line 144) - User extension methods return
{}(nodataHandlesproperty), soresult.dataHandlesisundefined - The driver falls back to
[]viaresult.dataHandles ?? []
The handles accumulated by createResourceWriter via getHandles() are never collected.
Expected Behavior
dataArtifacts should contain the handles for all resources written via context.writeResource() during method execution.
Suggested Fix
In RawExecutionDriver.execute():
- Also destructure
getHandlesfromcreateResourceWriter() - After method execution, fall back to
getHandles()whenresult.dataHandlesis empty:
const writerHandles = getHandles();
const allHandles = result.dataHandles?.length ? result.dataHandles : writerHandles;
const outputs = allHandles.map((handle) => ({ kind: "persisted" as const, handle }));This mirrors how the Docker execution driver works — it captures resources from the runner's output array rather than relying on the method's return value.
Affected Component
src/domain/drivers/raw_execution_driver.ts — the default execution driver for all extension models.
Environment
- swamp version: 20260328.174132.0-sha.5388e901
- Platform: macOS Darwin 23.6.0