Skip to content

fix(grpc): MilpacsService error-handling cleanups (#98)#107

Merged
SyniRon merged 3 commits into
developfrom
agent/issue-98
May 31, 2026
Merged

fix(grpc): MilpacsService error-handling cleanups (#98)#107
SyniRon merged 3 commits into
developfrom
agent/issue-98

Conversation

@SyniRon
Copy link
Copy Markdown
Collaborator

@SyniRon SyniRon commented May 31, 2026

Closes #98

Three adjacent error-handling cleanups in MilpacsService, one commit each:

  1. fix(grpc) null roster typeGetRoster/GetLiteRoster/GetS1UniformsRoster now return status.Errorf(codes.InvalidArgument, ...) instead of bare errors.New, so grpc-gateway maps to HTTP 400 (not 500) on ROSTER_TYPE_UNSPECIFIED.
  2. fix(grpc) empty keycloak/discord idGetUserViaKeycloakId/GetUserViaDiscordId early-return codes.InvalidArgument instead of warn-and-fall-through with an empty string, mirroring GetGamertagProfile.
  3. chore(datastores) %w wrapFindProfileByKeycloakID, FindProfileByDiscordID, and the FindS1UniformsRosterByType inline loop now wrap with error generating profile: %w, matching the other finders. Enables future errors.Is.

Notes / deviations

  • GetGamertagProfile already had the early-return pattern (triage comment was stale) — left unchanged, added a regression-guard test.
  • Item 3 has no observable consumer change today (handler maps all to codes.Internal); verified via grep (zero bare-string variants remain) + stdlib %w guarantee rather than a fragile sqlmock test.
  • GetUserViaKeycloakId is soft-deprecated — cleanup applied in place, no new dependencies added.

Tests

servers/grpc/milpacs_test.go: +6 behavioral tests (3 null-roster-type, 3 empty-id → InvalidArgument).

Gate

build ✅ · go test ./... ✅ · buf lint + buf breaking --against develop

🤖 Generated with Claude Code

SyniRon and others added 3 commits May 30, 2026 23:12
GetRoster / GetLiteRoster / GetS1UniformsRoster rejected
ROSTER_TYPE_UNSPECIFIED with a bare errors.New, which grpc-gateway maps
to codes.Unknown -> HTTP 500. A bad enum from the consumer is the
canonical 400 case; swap to status.Errorf(codes.InvalidArgument, ...).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
GetUserViaKeycloakId and GetUserViaDiscordId logged a warning then fell
through to the datastore lookup with an empty string, yielding a 404 or
500. Mirror GetGamertagProfile: early-return
status.Errorf(codes.InvalidArgument, ...) so the consumer gets a 400 and
no datastore call is made.

KeycloakId path is soft-deprecated (see CLAUDE.md); cleaned in place, no
new dependency added.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
FindProfileByKeycloakID, FindProfileByDiscordID, and the S1-uniforms
inline loop in FindS1UniformsRosterByType returned
fmt.Errorf("error generating profile") with no %w, unlike the other
finders. Wrap the underlying err so errors.Is works across the board.
No observable consumer change today (handler maps all to codes.Internal).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@SyniRon SyniRon merged commit 93488af into develop May 31, 2026
2 checks passed
@SyniRon SyniRon deleted the agent/issue-98 branch May 31, 2026 12:51
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.

MilpacsService — three adjacent error-handling cleanups (out of scope of #83)

1 participant