fix(OFFE-009): CU-17tkuw5uezw fetchChunks swallows failures with console.error instead of surfacing via toast/getErrorMessage - #542
Conversation
…ad of surfacing via toast/getErrorMessage
| const response = await apiClient.get<ChunkData[]>(url); | ||
|
|
||
| if (!response.ok) { | ||
| console.error(`Failed to fetch ${chatType} chunks:`, response.status); | ||
| return []; | ||
| throw new Error(response.error || `Failed to fetch ${chatType} chunks (${response.status})`); | ||
| } | ||
|
|
||
| return response.data || []; |
There was a problem hiding this comment.
🦩 🟠 fetchChunks swallows failures with console.error instead of surfacing via toast/getErrorMessage
In fetchChunks (ticket-service.ts), replaced the console.error(...); return []; branch with throw new Error(response.error || ...), matching the error-surfacing pattern already used by sendMessage/approveRequest/rejectRequest in this same service class, so the failure propagates to the caller instead of being silently swallowed as an empty array. This is a service-layer file with no access to useToast/React hooks, so the actual toast/getErrorMessage presentation must happen in the calling component/hook that invokes fetchChunks (consistent with how other service methods in this file throw and presumably let callers handle UI feedback); that caller-side wiring is outside this file and not verified here, so full resolution of OFFE-009's "surface via toast" requirement depends on the call site already handling thrown errors from this service (as it apparently does for the sibling methods).
🤖 Prompt for AI agents
In src/app/(app)/tickets/services/ticket-service.ts around line 418, review and complete this code-review fix: fetchChunks swallows failures with console.error instead of surfacing via toast/getErrorMessage.
What the draft fix changed: In `fetchChunks` (ticket-service.ts), replaced the `console.error(...); return [];` branch with `throw new Error(response.error || ...)`, matching the error-surfacing pattern already used by `sendMessage`/`approveRequest`/`rejectRequest` in this same service class, so the failure propagates to the caller instead of being silently swallowed as an empty array. This is a service-layer file with no access to `useToast`/React hooks, so the actual toast/getErrorMessage presentation must happen in the calling component/hook that invokes `fetchChunks` (consistent with how other service methods in this file throw and presumably let callers handle UI feedback); that caller-side wiring is outside this file and not verified here, so full resolution of OFFE-009's "surface via toast" requirement depends on the call site already handling thrown errors from this service (as it apparently does for the sibling methods).
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.
fix confidence: 🔴 55 low — review closely — react 👍/👎 to teach the reviewer
Closes findings from rule OFFE-009 — fetchChunks swallows failures with console.error instead of surfacing via toast/getErrorMessage.
Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
src/app/(app)/tickets/services/ticket-service.ts:418What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.
Run: https://product-hub.flamingo.so/admin/code-review
Run id:
88e36ec6-9bb0-474f-b0a0-4def1af6bdb7Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.
ClickUp task: CU-17tkuw5uezw OpenFrame OSS frontend UI and billing fixes (4 PRs)