fix(client): use authenticatedFetch in update-adapter#91
Merged
DJJones66 merged 1 commit intofeature/braindrive-update-notification-library-migrationfrom Apr 24, 2026
Conversation
POST /api/updates/conversation/start was returning 401 in local auth mode because update-adapter used plain fetch() + buildLocalOwnerHeaders(), which works for public routes (GET /updates/status is in the publicRoutes set) but does not attach the Bearer access token required for protected routes. Swap to authenticatedFetch from auth-adapter.ts — it handles the Bearer token in local mode and merges in local-owner headers when auth_mode is local-owner, matching the pattern used by every other authed client adapter (see gateway-adapter.ts). Verified by running the fresh-owner flow on the branch: clicking "Update available" now returns 200 with status: started, bootstrap_sent: true. See thread 250 post #7 for the broader test-pass context. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
b4742e4
into
feature/braindrive-update-notification-library-migration
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
fetch→authenticatedFetchinupdate-adapter.tsso protected update routes get the Bearer access token inlocalauth modebuildLocalOwnerHeaders()call (theauthenticatedFetchwrapper handles auth headers internally, matching the pattern used bygateway-adapter.ts)Why
During end-to-end testing of this branch against a fresh-owner install, clicking the sidebar Update available indicator 401'd on
POST /api/updates/conversation/start. Root cause:update-adapter.tsused plainfetch()without a Bearer header.GET /api/updates/statushappens to work because it's in thepublicRoutesset, so the sidebar indicator rendered fine — but the moment the owner clicked it, the protected route rejected the request.Every other authed client adapter in this repo (see
gateway-adapter.ts) goes throughauthenticatedFetch, which:localmodelocal-ownermodeThis PR brings
update-adapter.tsin line with that pattern.See the broader test-pass write-up and design decisions in community thread 250, post #7: https://community.braindrive.ai/t/braindrive-update-system/250/7
Test plan
POST /api/updates/conversation/startreturns 200 withstatus: started,bootstrap_sent: truelocal-ownerauth mode: not yet explicitly tested —authenticatedFetchis supposed to cover both modes via its mode-switch branch, but worth a smoke check if you exercise that pathRelated
🤖 Generated with Claude Code