Improve API error diagnostics, validation, and retry UX#23
Improve API error diagnostics, validation, and retry UX#23
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7a700c062d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| breadcrumbs: [...window.$ErrorLogger.getBreadcrumbs()], | ||
| }); | ||
| showRetryableApiError(`Invalid response from ${npath}`); | ||
| return data; |
There was a problem hiding this comment.
Reject invalid API response shapes
When response.json() returns a non-object payload, this branch logs and shows a dialog but still resolves the promise with the raw value, which violates getData’s typed Promise<APIResult<...>> contract and pushes the failure into callers that immediately dereference re.Status/re.Data. Before this change, malformed payloads like null would fail inside getData; now they can escape as “successful” results and trigger downstream runtime errors in unrelated components.
Useful? React with 👍 / 👎.
| showRetryableApiError( | ||
| `${npath} returned business status ${String(data.Status ?? "unknown")}`, | ||
| ); |
There was a problem hiding this comment.
Limit retry modal to truly retryable failures
This now opens the global retry dialog for every business-level non-200 response, including expected validation outcomes that the caller already handles (for example /Users/Follow returns 400 for self-follow and the UI shows a specific message). The result is duplicate/conflicting error UX and a misleading “network error” retry prompt for non-retryable user-input errors.
Useful? React with 👍 / 👎.
Motivation
cannot read properties of undefinederrors caused by malformed or non-JSON API responses by validating and surfacing those failures earlier.Description
src/services/errorLogger.tsto always callconsole.error(...)with the originalErrorobject or full stack so browser consoles retain full expandable stacks.stackstring for each saved error.getDatainsrc/services/api/getData.tsto validate response shape, log malformed responses, and treat JSON parse failures as network errors.showAPiError) for HTTP non-2xx responses, malformed/non-object responses, and business-levelStatus !== 200responses; these cases now log to the error logger and offer a retry handler that re-invokes the originalgetDatacall.Testing
npm run build, which includesvue-tscandvite build, and it completed successfully.src/services/errorLogger.tsandsrc/services/api/getData.tsare type-checked as part of the build.Codex Task