Skip to content

fix: handle unexpected commit graph scales gracefully - #12

Merged
offskip-dave merged 2 commits into
offskip-dave:mainfrom
shanesmithdev:fix/unknown-activity-scale
Nov 21, 2026
Merged

offskip-dave merged 2 commits into
offskip-dave:mainfrom
shanesmithdev:fix/unknown-activity-scale

Conversation

@shanesmithdev

@shanesmithdev shanesmithdev commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

A profile's commit activity comes from /api/v1 with a scale of day, week, month or year. 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 scale that is null or 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 half scale: 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.scale now reads a scale the app doesn't know, or one that's missing or not a string, as year, keeping its buckets.
  • The graph then draws it on the year's week grid, one column per week, and the header reads "N commits in the last year".
  • For half, that's 26 columns. The count is right, because devnull only sends half when nothing visible is older than 26 weeks (if the dependent PR is merged; otherwise it never sends half).

The app still only knows day, week, month and year, so nothing here depends on dev-null-sh/dev-null.sh#1658. If that is merged, we can add support for half (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_year in crates/devnull-api/tests/signing.rs, reads a profile whose scale is an unknown quarter, an array, null, a number, or missing entirely.

  • Without the change, it fails on the first case: left "quarter", right "year".
  • With the scale's default = "year_scale" removed, it fails on the missing case: left "", right "year".
  • CI passes on both jobs: Format, Clippy and Test on Ubuntu, and Clippy and Test on macOS.

I didn't run this against a live API. It needs the API to send an unknown scale to reproduce it.

Screenshots

  • No visible change for the scales the API sends today

Copilot AI balanced review requested due to automatic review settings November 21, 2026 09:22
@offskip-dave
offskip-dave requested a review from Cloudef November 21, 2026 09:24
@shanesmithdev
shanesmithdev marked this pull request as draft November 21, 2026 09:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.scale to treat unknown/non-string values as "year" while preserving buckets.
  • Add a regression test covering unexpected activity.scale payload 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.

Comment thread crates/devnull-api/src/types.rs Resolved
Comment thread crates/devnull-api/tests/signing.rs Resolved
@shanesmithdev
shanesmithdev force-pushed the fix/unknown-activity-scale branch from 08ba729 to d75b146 Compare November 21, 2026 09:47
@shanesmithdev
shanesmithdev requested a balanced review from Copilot November 21, 2026 09:52
@shanesmithdev
shanesmithdev marked this pull request as ready for review November 21, 2026 09:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@offskip-dave offskip-dave left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@offskip-dave
offskip-dave merged commit d74d310 into offskip-dave:main Nov 21, 2026
2 checks passed
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.

3 participants