Uh oh!
There was an error while loading. Please reload this page.
fix(cli): telemetry json parse crash - #5405
Conversation
9d187b0 to
27e0cbeCompare| function parseTelemetryConfig(content: string): TelemetryConfig | null { | ||
| try { | ||
| return JSON.parse(content) as TelemetryConfig; | ||
| } catch { |
There was a problem hiding this comment.
failing here bricks commands like supabase start on corrupted local telemetry state,
so returning null lets the existing first run path regenerate telemetry.json :D
There was a problem hiding this comment.
Thanks again for jumping on this and fixing the immediate crash. I agree with the core behavior here: malformed telemetry state should never crash unrelated CLI commands, and treating it as absent local state is the right outcome.
I opened a follow-up PR to align the implementation a bit more with the Effect style we’re using in the TypeScript CLI: #5412
The main changes are:
- avoid raw
JSON.parsefor local state files and decode throughEffectSchema.fromJsonString(...)instead - avoid
as TelemetryConfigcasts, since they can make structurally invalid JSON look valid to TypeScript - avoid
nullinternally and useOptionfor absent config, while still outputtingnullat JSON/API boundaries where that is the expected serialized value
So the user-facing fix remains the same, but malformed JSON and valid-but-wrong-shape JSON are both handled safely and silently.
Uh oh!
There was an error while loading. Please reload this page.
## Summary Telemetry config loading now uses an Effect Schema boundary instead of a raw `JSON.parse` cast. Invalid, unreadable, or malformed `telemetry.json` is treated as absent local telemetry state, so telemetry state cannot crash unrelated CLI commands. The telemetry config type is now derived from the runtime schema, and internal absence is represented with `Option` rather than `null`. `telemetry status` still serializes missing persisted consent as `null` at the output boundary. ## Context PR #5405 fixed the immediate empty JSON crash by catching parse errors, but structurally invalid JSON could still be accepted as `TelemetryConfig`. This follows the existing repo pattern of `Schema.fromJsonString(...)` for local state files and keeps malformed telemetry state best-effort and silent.
fixes
supabase startcrashing withJSON Parse error: Unexpected EOFfrom a malformedtelemetry.jsonbyrecovering and regenerating unreadable telemetry state