Skip to content

RawExecutionDriver ignores getHandles — writeResource produces empty dataArtifacts #907

@umag

Description

@umag

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

  1. Create any extension model with a method that calls context.writeResource()
  2. Run the method: swamp model method run <name> <method> --json
  3. 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):

  1. createResourceWriter() returns { writeResource, getHandles } but only writeResource is destructured — getHandles is ignored (line 89-91)
  2. writeResource is injected into the context and correctly persists data to disk
  3. After method execution, the driver reads result.dataHandles from the method's return value (line 144)
  4. User extension methods return {} (no dataHandles property), so result.dataHandles is undefined
  5. The driver falls back to [] via result.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 getHandles from createResourceWriter()
  • After method execution, fall back to getHandles() when result.dataHandles is 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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinglifecycle/doneCompleted and merged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions