CRY-58: fix(linear): normalize malformed responses in User.Read.ByTeam - #147
Conversation
Replace the fragile two-step with-match with a single deep pattern match consistent with Label.Read.ByTeam, WorkflowState.Read.ByTeam, and Project.Read.ByTeam. The prior code let a bare map escape the else clause when the team object existed but the members/nodes keys were absent, which would propagate up to callers expecting an ok/error tuple. Add test coverage for valid responses, null team, missing members key, missing nodes key, and API errors. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code ReviewIssue: CRY-58 — Normalize malformed responses in User.Read.ByTeam SummarySingle-commit change that replaces a fragile two-step CorrectnessNo issues found. The fix correctly addresses the root cause:
I verified
ConsistencyThe pattern now matches all three sibling ByTeam modules exactly:
The User module is actually more defensive than the siblings — those three omit the TestsFive new tests covering all specified edge cases via the code interface (
Tests use Quality Suite
Overall AssessmentApprove. The change is minimal, correct, well-tested, and consistent with project conventions. No issues found. |
Summary
Fixes a defensive-coding gap in
User.Read.ByTeamwhere malformed orpartially-populated API responses could leak a bare map out of the
elseclause instead of returning a proper
{:ok, []}or{:error, _}tuple.withmatch (extract team, then match members) with asingle deep pattern match, consistent with
Label.Read.ByTeam,WorkflowState.Read.ByTeam, andProject.Read.ByTeam.elsecatch-all{:ok, _} -> {:ok, []}now correctly handles nullteam, missing
memberskey, and missingnodeskey as graceful emptyresults.
missing nodes key, and API error propagation.
Closes CRY-58.
Test plan
mix test test/linear_cli/linear/user_test.exs— all 6 tests passmix compile --warnings-as-errors— cleanmix test— 260/267 pass; 7 failures are pre-existingGitTestenvironment failures unrelated to this change🤖 Generated with Claude Code