Skip to content

πŸ§‘β€πŸ’» chore(logging): say which field failed to decode, not just that one did - #53

Open
hub2rock wants to merge 1 commit into
mainfrom
chore/decoding-diagnostics
Open

πŸ§‘β€πŸ’» chore(logging): say which field failed to decode, not just that one did#53
hub2rock wants to merge 1 commit into
mainfrom
chore/decoding-diagnostics

Conversation

@hub2rock

Copy link
Copy Markdown
Contributor

Twice now a PLANKA schema drift has arrived as "couldn't read the server's response" β€” once for the terms payload, once on the projects screen β€” and both times finding the culprit meant querying the API by hand and diffing payloads against the models.

That guesswork was never necessary. DecodingError knows exactly which key failed and where; it was being thrown away, because localizedDescription on it is always the same sentence regardless of the cause.

Change

Both decode sites now log the diagnosis alongside the type and path:

missing key 'role' at included.users[3]
expected Bool at included.users[0].isDeactivated
null where non-optional String expected at included.users[0].role
corrupted value at items[2].createdAt: Date string does not match format

The generic copy stays on screen β€” this is for the log, where BoardlyLog.tag(.network) already reports decode failures.

Privacy

Only the shape is reported: coding path, expected type, reason. No decoded value is included, so nothing a user typed can reach the log through this. (dataCorrupted carries the decoder's own debugDescription, which describes a format problem β€” a malformed date, say β€” not user content.)

Tests

181 passing, 5 new, covering each DecodingError kind, a failure at the root object, and non-decoding errors keeping their own description.

Context

The projects-screen decode failure that prompted this is not fixed here β€” it is still unidentified, because the models match planka-openapi.json exactly, so the drift is between the spec and the live server. This is what makes the next report diagnosable from a log line instead of a round of API archaeology.

πŸ€– Generated with Claude Code

…ne did

`DecodingError.localizedDescription` is always the same sentence β€” "the data
couldn't be read because it isn't in the correct format" β€” so a schema drift
between PLANKA versions arrived as an unfalsifiable "couldn't read the server's
response", both on screen and in the log. Everything needed to locate it was
already in the error's context; it was simply discarded.

Both decode sites now log the diagnosis: `missing key 'role' at
included.users[3]`, `expected Bool at included.users[0].isDeactivated`, and so
on. The generic copy stays on screen β€” this is for the log.

Only the shape is reported: coding path, expected type, reason. No decoded value
reaches the log, so nothing a user typed can leak through it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant