Skip to content

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

@SyniRon

Description

@SyniRon

Three small inconsistencies surfaced during scoping of the
"every error becomes 404" fix (PR #83); none of them were that bug, so
they were flagged out-of-scope in the spec. Unblocked now that #83 has
merged. Bundle into a single chore PR.

  1. Roster handlers use plain errors.New instead of status.Errorf(codes.InvalidArgument, ...).
    GetRoster / GetLiteRoster / GetS1UniformsRoster all do
    return nil, errors.New("cannot request null roster type") on
    RosterType_ROSTER_TYPE_UNSPECIFIED. grpc-gateway wraps that as
    codes.Unknown → HTTP 500, when it should be
    codes.InvalidArgument → HTTP 400 (consumer sent a bad enum). Three
    one-line swaps.

  2. Empty Keycloak / Discord ID warn-but-continue.
    GetUserViaKeycloakId and GetUserViaDiscordId log a warning then
    fall through to the lookup with the empty string. Should early-return
    status.Errorf(codes.InvalidArgument, ...) like GetGamertagProfile
    already does. Two roughly-symmetric blocks.

  3. processProfiles-error wrap inconsistency.
    FindProfileByKeycloakID and FindProfileByDiscordID return
    fmt.Errorf("error generating profile") — no %w, no underlying err
    in the message. The other three single-row finders (FindProfilesById,
    FindProfilesByUsername, FindProfileByGamertag) all use
    fmt.Errorf("error generating profile: %w", err). The S1-uniforms
    inline loop (FindS1UniformsRosterByType) has the same bare-string
    outlier. Make all of them match. No observable consumer change today
    (handler maps all to codes.Internal), but the inconsistency will
    break a future errors.Is check the moment one is added.

Bundled because they all touch the same files and split cleanly per
commit.

Metadata

Metadata

Assignees

Labels

7cavchoreRoutine maintenance, cleanup, or tech-debt removalready-for-agentFully specified, ready for an AFK agent to implement

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions