refactor(cli): various cleanups and bug fixes#6262
refactor(cli): various cleanups and bug fixes#6262geovannewashington wants to merge 6 commits intomasterfrom
Conversation
|
Claude finished @geovannewashington's task in 6m 56s —— View job Code Review CompleteReviewed 10 files across code quality, security, testing, Go patterns, and architecture — 1 issue found. Test assertion not updated for
|
UserList was returning the raw store error directly, unlike every other service method which translates store errors into sentinel values from errors.go. This leaks implementation details to the cmd layer and breaks the consistency of the error handling pattern.
NamespaceDelete.Namespace had no validate tag, unlike every other input struct. Cobra's ExactArgs(1) only enforces argument count, not content, so invalid namespace names like "My.Namespace" or "UPPERCASE" would pass through to the store instead of being rejected early with a clear error.
namespaceInspect was calling UserResolve once per namespace member inside a loop, plus a separate call for the owner. For a namespace with N members this resulted in N+1 DB round trips. Replace with a single UserList call upfront, building an in-memory map for O(1) lookups of both the owner and all members.
UserList was the only method in UserStore without a doc comment, inconsistent with the rest of the interface.
These commands were marked for removal in v0.16.0, over two years and eight minor versions ago. All functionality has been available through the current command structure (cli user *, cli namespace *) since then. Removed with team approval.
getMaxDevices() is only called by NamespaceCreate, so it has no reason to live in its own file. Moved it to namespaces.go where it is used and deleted utils.go.
93899c7 to
c1238f2
Compare
|
/review |
|
Claude finished @otavio's task in 6m 12s —— View job Code Review CompleteReviewed 10 files across code quality, security, testing, Go patterns, and architecture — no issues found. The code looks good as-is. The issue from the previous review ( If you push additional changes and want a new review, tag |
What changed?
A series of small correctness fixes and cleanups across the CLI service
and command layers.
Why
UserListwas returning raw store errors directly, unlike every otherservice method which wraps them in sentinel values from
errors.go.This leaked implementation details to the
cmdlayer.NamespaceDelete.Namespacehad no validation tag. Cobra'sExactArgsonly enforces argument count - invalid names like
My.Namespacewerereaching the store instead of being rejected early with a clear error.
namespaceInspectwas making N+1 DB round trips - oneUserResolvecall per member plus a separate one for the owner. Replaced with a
single
UserListcall upfront and an in-memory map for lookups,bringing it down to 2 queries regardless of member count.
Deprecated commands had been marked for removal since v0.16.0, over
two years and eight minor versions ago. Removed with team approval.
getMaxDevices()lived in its ownutils.gofile despite being asingle function called only by
NamespaceCreate. Moved tonamespaces.goand deleted the file.Added the missing doc comment to
UserListin theUserStoreinterface, which was the only method without one.
How to test
./bin/docker-compose up -d