Commit 304c202
CRY-58: fix(linear): normalize malformed responses in User.Read.ByTeam (#147)
## Summary
Fixes a defensive-coding gap in `User.Read.ByTeam` where malformed or
partially-populated API responses could leak a bare map out of the
`else`
clause instead of returning a proper `{:ok, []}` or `{:error, _}` tuple.
- Replace the two-step `with` match (extract team, then match members)
with a
single deep pattern match, consistent with `Label.Read.ByTeam`,
`WorkflowState.Read.ByTeam`, and `Project.Read.ByTeam`.
- The `else` catch-all `{:ok, _} -> {:ok, []}` now correctly handles
null
team, missing `members` key, and missing `nodes` key as graceful empty
results.
- Add 5 new tests covering: valid response, null team, missing members
key,
missing nodes key, and API error propagation.
Closes CRY-58.
## Test plan
- [x] `mix test test/linear_cli/linear/user_test.exs` — all 6 tests pass
- [x] `mix compile --warnings-as-errors` — clean
- [x] `mix test` — 260/267 pass; 7 failures are pre-existing `GitTest`
environment failures unrelated to this change
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 39dfd80 commit 304c202
2 files changed
Lines changed: 54 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
78 | | - | |
| 77 | + | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
6 | 58 | | |
7 | 59 | | |
8 | 60 | | |
| |||
0 commit comments