Commit 7133988
fix(pi): keep the cause in the ListModels error chain
Trail #193 finding 019fb4fa-0f6 (low): pi/models.go used %s instead of %w, so
runErr dropped out of the error chain entirely and callers could not ask
errors.Is(err, exec.ErrNotFound) — i.e. "is pi installed?" — programmatically.
Mine, from the same commit that moved ListModels off HandleTextGenResult.
Wrapping naively duplicated the text, because detail falls back to
runErr.Error() when the subprocess produced no output. When there is no output,
runErr is the whole story, so it is now wrapped alone rather than interpolated
and then wrapped again.
TestListModels_PreservesCauseAndStaysUntyped pins both halves and both
directions: the cause is reachable via errors.Is, it appears exactly once, and
the error is deliberately NOT an *agent.TextGenError — listing models is not
summary generation, and routing it through that surface would let a
model-listing failure render as "Pi failed to generate the summary".
Also rewrote the streamFailure doc comment in the present tense. Trail finding
019fb472-90c reported the streaming path as still returning bare fmt.Errorf,
citing "lines 100/148" — the pre-fix layout. Those returns were migrated in
6e5c089 and the finding's own location (line 174) landed inside the comment
describing the OLD behavior. The comment now states what the code does rather
than what it used to do, so it cannot be read as a description of current
behavior.
Verified: zero bare fmt.Errorf/errors.New failure returns remain in
generate_streaming.go; 8573 unit tests; lint 0 issues on a cleaned cache.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 6e5c089 commit 7133988
3 files changed
Lines changed: 61 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
183 | 185 | | |
184 | 186 | | |
185 | 187 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
31 | | - | |
| 36 | + | |
32 | 37 | | |
33 | | - | |
| 38 | + | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
4 | 12 | | |
5 | 13 | | |
6 | 14 | | |
| |||
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
0 commit comments