Skip to content

fix(mark-notification-read): treat a null run_started_at as absent - #862

Merged
max-sixty merged 1 commit into
mainfrom
fix/notification-null-timestamp
Aug 8, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/notification-null-timestamp

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Problem

#843 added a guard so a transient failure fetching run_started_at leaves the notification unread rather than failing the step. It tests [ -z "$RUN_STARTED_AT" ], which covers a gh api that exits non-zero — but not a 200 whose body lacks the field. gh --jq prints the literal string null there, which is non-empty and passes -z.

null then reaches the filter as a string:

jq -r --arg started "$RUN_STARTED_AT" '.[] | select(.subject.url == $url and .updated_at <= $started) | .id'

Every ISO-8601 timestamp sorts before null by codepoint (2 is 0x32, n is 0x6e), so updated_at <= "null" is true for every thread. The step marks read exactly the mid-run activity the guard exists to preserve — silently, since it's the success path.

Reproduced against the real script with the existing test_shared_steps.py fake gh, using a notification dated two months after the run started:

$ FAKE_RUN_STARTED_AT=null bash shared/steps/mark-notification-read.sh
$ cat gh-calls.log
api repos/owner/repo/actions/runs/12345 --jq .run_started_at
api notifications
api notifications/threads/999 -X PATCH     # ← marked read anyway

Fix

Extend the guard to treat null as absent, so the missing-field case takes the same skip-this-cycle path as a failed fetch:

|| [ -z "$RUN_STARTED_AT" ] || [ "$RUN_STARTED_AT" = "null" ]; then

Plus a regression test that asserts nothing is marked read against a null timestamp. It fails on main with marked a thread read against a null run_started_at and passes with the fix.

On reachability

I want to be straight about this: I could not construct a live case where /actions/runs/{id} returns 200 without run_started_at — the field has been on that endpoint for years, and an HTTP error exits gh non-zero and is already handled. So this is hardening against a shape the API doesn't currently produce, not a bug anyone is hitting.

What makes it worth the two lines is the failure mode rather than its likelihood: the wrong branch is the success path, it swallows unread notifications instead of erroring, and #843 already decided this is a place where being wrong should cost a skipped cycle and not silent data loss. Happy for it to be closed if that's the wrong trade.

@max-sixty
max-sixty merged commit e77450a into main Aug 8, 2026
5 checks passed
@max-sixty
max-sixty deleted the fix/notification-null-timestamp branch August 8, 2026 16:04
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.

2 participants