Skip to content

fix(service,user): errors read as the convention says - #575

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

retr0h merged 1 commit into
mainfrom
fix/service-user-error-shape

Conversation

@retr0h

@retr0h retr0h commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

The last two providers from #565. 13 files. With #573 and #574 this completes the convention across all six.

service   service: create: %w          ->  service create: %w
          invalid service name: empty  ->  service: name must not be empty
          daemon-reload: %w            ->  service reload: daemon-reload: %w

user      chpasswd failed: %w          ->  chpasswd: %w  (wrapped by user set-password:)
          user: useradd failed: %w     ->  user create: useradd: %w
          user: userdel failed: %w     ->  user delete: userdel: %w
          group: groupadd failed: %w   ->  group create: groupadd: %w

service was a colon away from the convention, so every operation reported service: and the verb read as part of the message rather than as the operation.

user named commands rather than operations. chpasswd failed stops being true the day the implementation changes, and a CLI user has no reason to know which binary runs underneath. The command survives as detail rather than as the subject.

Three things the tests caught, all the same shape

Prefixing an error a caller already wraps doubles the domain. Hit the password hash validation, the name validation and chpasswd:

user set-password: user set-password: chpasswd: chpasswd failed
user: user: password hash must not contain a colon or line break

A sed over test files hit a mock's command argument, rewriting the systemctl argument "daemon-reload" rather than the message about it. The mock then expected a flag that does not exist.

Not changed

validate.go keeps its shared invalid %s name %q wording. It is used by both user and group, and changing it means changing a signature, so it belongs in a change that can be about that alone. Worth a follow-up.

Checks

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

🤖 Generated with Claude Code

https://claude.ai/code/session_01FuKUsHFG1EqZXamffh9M2c

The last two providers from #565.

service used <domain>: <verb>, a colon away from the convention, so every
operation reported "service: " and the verb read as part of the message
rather than as the operation.

user named commands rather than operations: chpasswd failed, useradd
failed, groupadd failed. Those stop being true the day the implementation
changes, and a CLI user has no reason to know which binary runs underneath.
They now read "user create: useradd: ..." and "user set-password:
chpasswd: ...", keeping the command as detail rather than as the subject.

Three things the tests caught, all the same shape. Prefixing an error that
a caller already wraps doubles the domain, which happened to the password
hash and name validations and to chpasswd. And a sed over test files hit a
mock's command argument, rewriting the systemctl argument "daemon-reload"
rather than the message about it.

validate.go keeps its shared "invalid %s name %q" wording. It is used by
both user and group and changing it means changing a signature, so it is
left for a change that can be about that alone.

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     #575   +/-   ##
=======================================
  Coverage   99.95%   99.95%           
=======================================
  Files         501      501           
  Lines       24073    24073           
=======================================
  Hits        24063    24063           
  Misses         10       10           
Files with missing lines Coverage Δ
internal/provider/node/service/debian.go 100.00% <100.00%> (ø)
internal/provider/node/service/debian_action.go 100.00% <100.00%> (ø)
internal/provider/node/service/debian_get.go 100.00% <100.00%> (ø)
internal/provider/node/service/debian_list.go 100.00% <100.00%> (ø)
internal/provider/node/service/debian_unit.go 100.00% <100.00%> (ø)
internal/provider/node/user/debian_group.go 100.00% <100.00%> (ø)
internal/provider/node/user/debian_user.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 97e0102...850ba2a. 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 722a54b into main Oct 2, 2026
12 checks passed
@retr0h
retr0h deleted the fix/service-user-error-shape branch October 2, 2026 17:39
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