Repository navigation
fix: handle unexpected commit graph scales gracefully - #12
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Minor inconsistencies remain between the PR’s stated intent and the covered behavior—deserialize_scale doesn’t explicitly handle the known "year" value, and the tests don’t include a case for a missing activity.scale defaulting to "year", leaving small gaps that should be tightened up.
2 open issues
What changed in this PR
Makes profile commit-activity decoding resilient to unexpected/malformed activity.scale values by defaulting/coercing them to "year" so the UI uses the year/week-grid layout instead of an unreadable short-scale strip.
Changes:
- Add a default + custom deserializer for
Activity.scaleto treat unknown/non-string values as"year"while preserving buckets. - Add a regression test covering unexpected
activity.scalepayload shapes (unknown string, array,null, number).
| File | Description |
|---|---|
| crates/devnull-api/tests/signing.rs | Adds an integration test ensuring profiles still decode activity buckets when activity.scale is present but unexpected or malformed, treating it as "year". |
| crates/devnull-api/src/types.rs | Updates Activity.scale deserialization/defaulting to coerce unknown or non-string scales to "year" to avoid decode failures and bad graph layout. |
Review effort: Balanced
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
08ba729 to
d75b146
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The change is limited to adding a safe default for malformed or missing activity scale values and includes a regression test covering unknown/null/non-string/omitted cases, indicating no remaining issues to address.
No open issues 🎉
2 resolved since last review
Review effort: Balanced

A profile's commit activity comes from
/api/v1with ascaleofday,week,monthoryear. If the scale was anything else, the app drew it as the one-row strip used for the short scales.With months of daily buckets and an unknown scale sent by the API, every square ends up a fraction of a pixel wide, so the graph will look blank under a pile of overlapping date labels.
A profile with no commits says "No commits yet" instead of showing an empty grid. A
scalethat isnullor not a string, such as an array, fails to decode, so the profile shows no commit activity at all.dev-null-sh/dev-null.sh#1658 proposes a
halfscale: 26 weeks of daily buckets for profiles 30 days to 6 months old. Without this change, someone two months in would see an unreadable graph in the app as soon as that ships. That PR may not merge, but devnull could add a scale at any time, so this makes the app ready for one either way.Fix
Activity.scalenow reads a scale the app doesn't know, or one that's missing or not a string, asyear, keeping its buckets.half, that's 26 columns. The count is right, because devnull only sendshalfwhen nothing visible is older than 26 weeks (if the dependent PR is merged; otherwise it never sendshalf).The app still only knows
day,week,monthandyear, so nothing here depends on dev-null-sh/dev-null.sh#1658. If that is merged, we can add support forhalf(or any future scale) at our own pace without the app showing a broken graph.Tests
A new test,
profile_reads_an_unexpected_activity_scale_as_a_yearincrates/devnull-api/tests/signing.rs, reads a profile whose scale is an unknownquarter, an array,null, a number, or missing entirely."quarter", right"year".default = "year_scale"removed, it fails on the missing case: left"", right"year".I didn't run this against a live API. It needs the API to send an unknown scale to reproduce it.
Screenshots