Repository navigation
Handle the journal's 204 and JOURNAL_NOT_FOUND signals explicitly - #2
Merged
Merged
Conversation
added 3 commits
October 21, 2026 15:26
WebhooksJournal's /earliest and /latest return 204 No Content with an empty body when an app has no journal entries; they never return 404 for that. The poller only worked because axios hands back '' for a 204, which happened to be falsy. Worse, it mapped 404 to "no entries", so a 404 from a missing route (for example the 2027-03-beta version being retired) would log "No journal entries available yet" forever instead of an error.
batch/{offset}/next returns a JSON 404 whose subCategory is
WebhooksJournalErrorType.JOURNAL_NOT_FOUND when an offset has expired. A
retired or mistyped API version also returns 404, but as an HTML page.
Treating every 404 as an expired offset would wipe the cursor on each
poll instead of reporting the real problem.
The README now spells out how each endpoint signals empty and not found
(204 vs 200 with empty results vs JOURNAL_NOT_FOUND), because apps
ported from this example to fetch crashed parsing the empty 204 body
that axios had been quietly absorbing.
zprobs
marked this pull request as ready for review
October 21, 2026 19:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
204 No Contentwith an empty body from/earliestand/latestwhen an app's journal is empty. It never returns 404 for that. The poller only worked because axios hands back""for a 204, and that happens to be falsy. Apps ported from this example tofetchcrashed parsing the empty body, and the example's "404 = no entries" handling taught the wrong signal.404whosesubCategoryisWebhooksJournalErrorType.JOURNAL_NOT_FOUND(expired offset). Any other 404 now surfaces as an error. An example is the HTML 404 returned once the2027-03-betaversion is retired after 2027-04-23. Previously that would have silently logged "no entries" forever or wiped the cursor on every poll.BRAVE Checklist
Backwards compatibility: none broken. Behavior is unchanged for 204, 200 and
JOURNAL_NOT_FOUND. The only change is that unexpected 404s are now logged as errors instead of being treated as an empty or expired journal.Roll(out/back) plan: example app with no deployment. Revert this PR to undo.
Automated testing: new
__tests__/poller.test.tswith 6 tests covering a 204 that clears the cursor, a 200 that moves the cursor, a 404 from/latestthat is surfaced, aJOURNAL_NOT_FOUNDbatch 404 that returns null, a non-JOURNAL_NOT_FOUND404 that is surfaced, and a normal batch. Both 404 tests fail against the previous code. Full suite: 20/20.Verification plan: ran the app locally against prod. It polled cleanly and a contact update flowed through end to end. Calls to the live API with a fresh app (empty journal) confirmed the shapes:
/earliestand/latestgive204with an empty body,batch/earliest|latestgives200 {results: []}withnumErrors/errorsomitted, and an unknown offset on/offset/{o}/nextandbatch/{o}/nextgives404withsubCategory: WebhooksJournalErrorType.JOURNAL_NOT_FOUND.Expect dependencies to fail: if the journal API changes these signals, the poller now fails loudly (error log) instead of silently assuming an empty journal.