Commit d02281c
authored
Phase 25: error-body-truncation (#506)
* docs: cross-AI review for phase 25
* fix(25): revise plans based on checker feedback
* docs(25): finalize verified phase plans
* test(25-01): pin shared error body sanitizer contract
- add shared sanitizer coverage for trim, rune-safe truncation, and exact [truncated] suffix
- update Perplexity error-path tests to expect the new truncation contract
- strengthen OpenRouter tests for raw fallback and structured error.message sanitization
* fix(25-01): share error body sanitization across providers
- add panic-safe SanitizeErrorBody in pkg/commons/http with trim, rune-limit, and [truncated] contract
- route Perplexity HTTP error formatting through the shared sanitizer and remove local truncation logic
- sanitize OpenRouter parsed error.message and raw fallback body text through the shared helper
* docs(25-01): complete error body truncation plan
- summarize the shared sanitizer contract and Perplexity/OpenRouter normalization work
- advance Phase 25 planning state to plan 2 of 4 and update roadmap progress
- mark ERR-01 complete while leaving ERR-02 pending for later provider migration plans
* test(25-02): add failing long-body provider regressions
- add OpenAI regression for truncated provider error bodies
- add Baseten regression for truncated provider error bodies
* fix(25-02): sanitize batch-a provider error bodies
- route OpenAI and Baseten raw HTTP bodies through the shared sanitizer
- sanitize Bedrock and Chroma Cloud provider error body segments
- preserve provider-specific status wording while truncating oversized payloads
* fix(25-03): sanitize provider error bodies in batch A
- preserve Cloudflare structured errors while truncating only the raw body tail
- route Cohere, Hugging Face, and Jina raw error text through SanitizeErrorBody
- add a focused Cloudflare regression for the mixed structured/raw error contract
* docs(25-02): add error-body-truncation summary
- record the 25-02 provider migration outcome and verification evidence
- capture task commits, decisions, and workflow deviations for this plan
* docs(25-03): complete error body truncation plan
- record the Cloudflare/Cohere/HF/Jina sanitizer slice summary
- update phase 25 state after completing plan 25-03 in the forked workspace
- refresh roadmap progress for the tracked phase summaries
* docs(25-03): sync tracked phase progress
- reflect the concurrent 25-02 summary in phase 25 progress counts
- restore state and roadmap to the current tracked 3/4 completion view
* fix(25-04): sanitize batch-B provider error bodies
- route the remaining raw-body provider errors through chttp.SanitizeErrorBody
- preserve each provider's existing status and endpoint wording
- keep the migration limited to the body-derived error segment
* test(25-04): add Twelve Labs truncation regressions
- pin a long structured message case that requires [truncated]
- pin a long raw fallback body case that rejects the full provider payload
- capture the approved body-derived text policy before implementation
* fix(25-04): sanitize Twelve Labs error bodies
- sanitize parsed apiErr.Message values as body-derived text
- sanitize the raw fallback response body path as well
- keep the existing Twelve Labs error wording intact
* test(25-04): verify full embedding sanitizer rollout
- run go test -tags=ef ./pkg/commons/http ./pkg/embeddings/... successfully
- confirm make lint is clean after the final provider migrations
- capture the green phase gate as the completion point for Task 3
* docs(25-04): complete error-body-truncation plan
- complete the batch-B and Twelve Labs sanitizer rollout summary
- update state, roadmap, and requirements for Phase 25 completion
- record verification evidence for the full embedding sweep and lint gate
* fix(25-03): sanitize non-json Cloudflare error bodies
- fall back to the shared sanitizer on non-JSON error responses\n- add a focused regression for plain-text gateway failures\n- keep the JSON structured-error path unchanged
* docs(25): add code review report
- capture the post-fix Phase 25 review findings\n- record the remaining non-blocking Cohere default-model warning
* docs(phase-25): complete phase execution
- add the Phase 25 verification report\n- record passed goal verification on the current codebase
* docs(phase-25): finalize state after verification
- mark Phase 25 as verified complete in STATE.md\n- advance the current focus to Phase 30\n- normalize the current-position fields after the partial phase-complete update
* test(25): complete UAT - 8 passed, 0 issues
* docs(25): add code review report
* fix(25): WR-03 restore cohere default model
* fix(25): WR-02 sanitize cloudflare structured errors
* fix(25): bound sanitizer allocations
* fix(25): WR-01 remove stale sanitizer path
* test(25): strengthen cloudflare structured error regression
* docs(25): add code review fix report
* Preserve structured embedding API error details
* docs(25): ship phase 25 — PR #506
* fix(25): sanitize parsed error fields and harden panic-recovery seam
Address PR #506 review feedback for error-body truncation:
- chromacloud, chromacloudsplade: wrap parsed embResp.Error with
SanitizeErrorBody so JSON-side error strings can't bypass the
512-rune display cap.
- openrouter: sanitize apiErr.Error.Code (typed any) by routing through
SanitizeErrorBody after %v formatting.
- twelvelabs: sanitize apiErr.Code in the structured-error branch.
- pkg/commons/http: replace mutable sanitizeErrorBodyFunc package var
with a private sanitizeErrorBodyWith(body, fn) helper; the panic
recovery test now injects via parameter and is parallel-safe.
Each provider fix ships with an httptest-based regression test that
fails before the fix and passes after.
* fix(25): restore ReadRespBody empty-string contract on read error
Commit 6407cc3 changed ReadRespBody to return a bracketed sentinel
("[failed to read response body: ...]") on ReadLimitedBody failure.
The seven v2-client callers in pkg/api/v2/client_http.go feed the
result into strconv.Atoi / json.Unmarshal / NewTenantFromJSON /
strings.Contains, so the sentinel surfaced as confusing parse errors
that obscured the real failure (oversize body or transport error).
Revert the error path to "", matching the historical 2024-era contract
that the v2 callers were written against. Keep the ReadLimitedBody
size cap (the legitimate defense from 6407cc3). Add a brief WHY
comment so the sentinel does not get re-introduced. Replace the
obsolete TestReadRespBodyReportsReadErrors with two parallel-safe
contract tests (read error + oversize body).
A proper (string, error) refactor remains owed as future work but is
out of Phase 25 scope.1 parent 5cab223 commit d02281c
47 files changed
Lines changed: 2597 additions & 83 deletions
File tree
- .planning
- phases/25-error-body-truncation
- pkg
- commons/http
- embeddings
- baseten
- bedrock
- chromacloudsplade
- chromacloud
- cloudflare
- cohere
- hf
- jina
- mistral
- morph
- nomic
- ollama
- openai
- openrouter
- perplexity
- roboflow
- together
- twelvelabs
- voyage
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
| 70 | + | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
116 | 119 | | |
117 | 120 | | |
118 | 121 | | |
| |||
196 | 199 | | |
197 | 200 | | |
198 | 201 | | |
199 | | - | |
| 202 | + | |
200 | 203 | | |
201 | 204 | | |
202 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
| 30 | + | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
49 | 62 | | |
50 | 63 | | |
51 | 64 | | |
| |||
57 | 70 | | |
58 | 71 | | |
59 | 72 | | |
60 | | - | |
61 | | - | |
| 73 | + | |
| 74 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 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 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
0 commit comments