Skip to content

fix(file): errors read as the convention says - #573

Merged
retr0h merged 1 commit into
mainfrom
fix/file-error-shape
Oct 2, 2026
Merged

retr0h merged 1 commit into
mainfrom
fix/file-error-shape

Conversation

@retr0h

@retr0h retr0h commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

First of the error-shape fixes from #565, following the convention merged as osapi-io/specs#245. 8 files.

The file provider carried the worst of the four shapes. Every error began failed to, which is the one Go's own guidance argues against: these are almost always wrapped, so the reader saw

deploy schedule entry: failed to execute template: ...

where the words carry nothing the context had not already supplied.

Now

file deploy: get object %q
file deploy: render template
file deploy: set ownership %q on %q
file template: parse template
file status: ...
file undeploy: ...

Named for the operation rather than for the fact that something went wrong.

Two things the tests caught

The ownership error spans two lines, so a regex anchored on fmt.Errorf("failed to missed it entirely.

The template failures are wrapped by deploy, not raised by template, so the real string is file deploy: render template: file template: execute template: .... My first pass guessed the prefix from the test file's name and asserted file template: render template, which never existed. Corrected by reading it off the actual error.

Scope

go test -count=1 ./internal/... is 41 packages, 0 failures.

Five providers still carry the older shapes: ntp and service use a bare <domain>:, certificate and schedule use <verb> <domain>:, and user has chpasswd failed:. Those are 81 more errors with test assertions on them, so they follow separately rather than riding along here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FuKUsHFG1EqZXamffh9M2c

Applies osapi-io/specs#245 to the file provider, which carried the worst of
the four shapes. Every error here began "failed to", which is the one Go's
own guidance argues against: these are almost always wrapped, so the reader
saw "deploy schedule entry: failed to execute template: ..." where the words
carried nothing the context had not.

They now read "file deploy: ...", "file template: ...", "file status: ..."
and "file undeploy: ...", named for the operation rather than for the fact
that something went wrong.

Two things the tests caught. The ownership error spans two lines, so a
regex anchored on fmt.Errorf missed it. And the template failures are
wrapped by deploy rather than raised by template, so the assertion naming
the originating operation was wrong until it was read off the actual error.

Five providers still carry the older shapes. This is the first.

Refs #565

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FuKUsHFG1EqZXamffh9M2c
@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #573   +/-   ##
=======================================
  Coverage   99.95%   99.95%           
=======================================
  Files         501      501           
  Lines       24073    24073           
=======================================
  Hits        24063    24063           
  Misses         10       10           
Files with missing lines Coverage Δ
internal/provider/file/deploy.go 100.00% <100.00%> (ø)
internal/provider/file/status.go 100.00% <100.00%> (ø)
internal/provider/file/template.go 100.00% <100.00%> (ø)
internal/provider/file/undeploy.go 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update acb9233...cecc46c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@retr0h
retr0h merged commit 97e0102 into main Oct 2, 2026
12 checks passed
@retr0h
retr0h deleted the fix/file-error-shape branch October 2, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant