Skip to content

fix: an empty delivered file is a broken delivery, refused by ReadFileCarrier - #849

Merged
antoinetoussaint-byte merged 1 commit into
mainfrom
fix/file-carrier-empty-is-broken
Oct 26, 2026
Merged

antoinetoussaint-byte merged 1 commit into
mainfrom
fix/file-carrier-empty-is-broken

Conversation

@antoinetoussaint-byte

Copy link
Copy Markdown
Contributor

Summary

resources.ReadFileCarrier now refuses a carrier whose file is empty, with ErrFileCarrier: <key>: delivered file is empty, the same way it refuses a missing file. ResolveFileCarriers, which reads through it, inherits the rule.

Why: a value is delivered by file only when it is larger than FileCarrierThreshold (deliverByFile). A carrier naming an empty file is therefore a truncated write or a mount race, never a value the host left unset. ReadFileCarrier returned "" for it, and a reader treats "" as absent, so a lookup could step past a broken delivery to another source. codefly-dev/sdk-go#90 hit this: WorkspaceValue answered from the secret namespace when the public value's delivered file was empty (review r144 f2). sdk-go now refuses an empty file in its own readFileCarrier. Review r154 f2 asked for the rule in core too, so every reader of file carriers gets it from the one function that reads them.

docs/runnable-binding-delivery.md's Read time rule lists an empty file among the refusals, with the reason.

Fix or hack

Fix, at the owner: ReadFileCarrier is the one function that reads carrier files. The change is one check there, beside the size check.

Test plan

  • TestResolveFileCarriersFailsClosed gains an an empty file case (expects ErrFileCarrier). With the check removed, it fails on that case.
  • go test -race -count=1 ./resources/ passes.
  • go test -count=1 ./runners/base/ passes. That is the other package that reads carriers (ResolveFileCarriers, in a test).
  • go vet ./resources/ is clean. golangci-lint run --new-from-rev=origin/main ./resources/... reports 0 issues. The gosec findings left in file_carrier.go are on lines this PR does not touch.
  • The full core suite was not run locally; CI runs it.

Producer side

Nothing produces an empty file carrier: deliverByFile sets File only when the value is above FileCarrierThreshold, and no other code sets it. This PR changes only what a reader accepts.

🤖 Generated with Claude Code

…eCarrier

A value is delivered by file only when it is larger than
FileCarrierThreshold (deliverByFile), so a carrier naming an empty file is a
truncated write or a mount race, never a value the host left unset.
ReadFileCarrier returned "" for it, which a reader treats as absent, so a
lookup could step past a broken delivery to another source. sdk-go#90 found
exactly that: WorkspaceValue answered from the secret namespace (review r144).
It now refuses with ErrFileCarrier ("delivered file is empty"), like a missing
file, so every reader of ResolveFileCarriers/ReadFileCarrier gets the rule
from the one place that reads carrier files (review r154 f2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@antoinetoussaint-byte
antoinetoussaint-byte merged commit cbc2820 into main Oct 26, 2026
10 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