fix(frontend): meaningful serverless metadata errors#5102
Conversation
|
🚅 Deployed to the rivet-pr-5102 environment in rivet-frontend
|
Code ReviewSummary: This PR correctly fixes the root cause. The old formatMetadataError was pattern-matching against camelCase TypeScript-generated discriminated-union keys (invalidRequest, nonSuccessStatus, etc.) while the actual wire format sends a message/details/metadata envelope with snake_case metadata.kind. Every variant silently fell through to 'Unknown error'. The new approach is more robust, surfaces the server human-readable message field directly, and degrades gracefully for unknown future variants. 1. Untruncated server body in UI error string (moderate) serverless-health-error.ts L49 appends metadata.body for non_success_status (and falls back to it for invalid_response_json when parse_error is absent) without any length cap. When a WAF, CDN, or misbehaving upstream returns a full HTML page as the response body, the UI renders the entire raw HTML inline as the error string. The existing network-error path in extractErrorMessage already applies .slice(0, 200) for this reason; the same cap should apply to any externally-sourced field appended by formatServerlessMetadataError. 2. Redundant .partial() on an already-optional schema (minor) serverless-health-error.ts L6-L17: all fields already carry .optional(), making the trailing .partial() call a no-op in Zod. Drop .partial() or the per-field .optional() calls to clarify intent. Positive notes: schema-based parsing with z.unknown() is the right fix; the forward-compat design (unknown kind -> surface message -> humanise kind -> generic fallback) is well tested; stories provide a clear visual audit trail; extracting the formatter into its own file improves testability. |
b2367df to
a6089de
Compare

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: