Skip to content

fix: promote a running step's outputs; answer 400 to a NUL byte in the URL - #770

Merged
artempartos merged 2 commits into
developfrom
artempartos/fix-promote-live-outputs
Nov 16, 2026
Merged

artempartos merged 2 commits into
developfrom
artempartos/fix-promote-live-outputs

Conversation

@artempartos

Copy link
Copy Markdown
Contributor

Two unrelated production fixes found while triaging errors.

1. promote_asset finds a file the running step wrote

A step's files in /workspace/outputs become run outputs (WorkflowRunAsset) only in
WorkflowStepStrategy#before_cleanup, after the session ends. promote_asset looked only
at run outputs, so a step whose instructions say "write report.md and promote it" always
failed with No workflow output asset named … found in this run. Agents in production
have started to note that the call "failed as expected".

  • promote_asset reads /workspace/outputs/<name> from the running container first
    (ContainerRuntime#read_file_result), and falls back to an earlier step's run output
    of that name. The step's own file wins: it is newer.
  • Refused: a name that leaves the outputs directory (../x), an empty file, and a file
    the runtime could not read whole (a runner without S3-compatible storage), with the
    reason in the error.
  • AssetExportService takes either a WorkflowRunAsset or the new LiveOutput (name +
    bytes); versioning by name and folder is unchanged.
  • share_asset explains in its description and its not-found error that a running
    session's outputs are shared by promoting them first.
  • /workspace/outputs was spelled out in four places; it is now Asset::OUTPUT_DIR.

2. A NUL byte in the URL answers 400, not 500

POST /webhooks/in/%00 raised ArgumentError: string contains null byte from the slug
lookup (Postgres rejects NUL in a text bind) and answered 500. Middleware::NullByteGuard
sits first in the stack and answers 400 to any request with a NUL byte (raw or %00) in
its path or query string, which covers every route that looks a record up by a path
param, not only the ingress one. %2500 (an encoded %00 literal) still passes.

Verification

  • New tests: live promote (nested name and folder), live file over an earlier run
    output, fallback to an earlier step's output, ../ refused, empty file refused, cut
    read refused; middleware unit test; ingress /webhooks/in/%00 → 400.
  • Reverting either fix makes the new tests fail.
  • Locally: the affected test files (270 runs), rubocop on the changed files and
    brakeman are clean. The full suite is left to CI.

Changelog: Assets entry under Fixed for the promote fix; the NUL-byte guard is
internal and has none.

🤖 Generated with Claude Code

artempartos and others added 2 commits November 16, 2026 21:39
A step's outputs become run outputs (WorkflowRunAsset) only when its
session ends, so promote_asset called mid-step never found the file the
step had just written and failed with "No workflow output asset named …".

promote_asset now reads the file from the running container first and
falls back to an earlier step's run output. A name that leaves the
outputs directory, an empty file and a file the runtime could not read
whole are refused. share_asset points at promote_asset for the same case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
Postgres rejects NUL in a text bind, so a lookup by such a path param
(/webhooks/in/%00) raised ArgumentError and answered 500. A middleware
at the top of the stack now refuses the request before any route sees it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
@artempartos
artempartos merged commit 8c78fd3 into develop Nov 16, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant