Skip to content

refactor(user): the caller names the resource, so the validator does not - #577

Merged
retr0h merged 1 commit into
mainfrom
fix/validate-account-name-signature
Oct 3, 2026
Merged

retr0h merged 1 commit into
mainfrom
fix/validate-account-name-signature

Conversation

@retr0h

@retr0h retr0h commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

The piece deliberately left out of #575. 6 files.

validateAccountName took a kind argument purely to put "user" or "group" into its message, and every one of its twelve callers then wrapped the result with that same word:

group: invalid group name "Invalid": must match ...
user: invalid user name "john:root": must match ...

Dropping the parameter gives:

group: name "Invalid" must match ^[a-z_][a-z0-9_-]*\$?$ and be at most 32 characters
ssh key: add: name "Invalid" must match ...

That is the rule the rest of #565 settled on: only the outermost frame names the operation. It is also the rule that would have prevented the four doubled-prefix mistakes this work hit along the way.

Why it was separate

It changes a function signature, which is a different kind of change from rewording a string. The signature is unexported and has twelve call sites all inside internal/provider/node/user, so nothing outside the package moves.

Checks

go vet ./internal/provider/node/user/ clean. go test -count=1 ./internal/provider/... is 25 packages, 0 failures.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FuKUsHFG1EqZXamffh9M2c

validateAccountName took a kind argument purely to put "user" or "group"
into its message, and every one of its twelve callers then wrapped the
result with that same word. The error read "group: invalid group name
%q: ...".

Dropping the parameter leaves "group: name %q must match ...", which is the
rule the rest of this work settled on: only the outermost frame names the
operation.

This was left out of #575 because it changes a signature. It is a signature
nobody outside the package uses, so the change is contained.

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 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #577   +/-   ##
=======================================
  Coverage   99.95%   99.95%           
=======================================
  Files         501      501           
  Lines       24073    24072    -1     
=======================================
- Hits        24063    24062    -1     
  Misses         10       10           
Files with missing lines Coverage Δ
internal/provider/node/user/debian_group.go 100.00% <100.00%> (ø)
internal/provider/node/user/debian_ssh_key.go 100.00% <100.00%> (ø)
internal/provider/node/user/debian_user.go 100.00% <100.00%> (ø)
internal/provider/node/user/validate.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 54fd63c...9bd6d53. 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 a3958d0 into main Oct 3, 2026
12 checks passed
@retr0h
retr0h deleted the fix/validate-account-name-signature branch October 3, 2026 19:08
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