fix: send credentials to the plugin endpoints so backend switching works - #122
Merged
Merged
Conversation
The storage backend is a per-user choice resolved from the request credentials (spec 007), but every frontend call to /api/plugins and /api/plugins/toggle used a bare fetch() with no credentials attached. The server therefore could not tell who was asking: - GET /api/plugins fell back to DEFAULT_STORAGE_BACKEND, so JSON on Google Drive rendered as active for everyone regardless of their actual choice. - POST /api/plugins/toggle returned 401 for any storage plugin, and togglePlugin silently reverted the checkbox — so no storage backend could be selected from the UI at all. This predates the pCloud plugin; switching to Sheets was equally broken. pCloud was simply the first backend switch attempted since spec 007. Adds pluginFetch(), which attaches credentials when present. Unlike authenticatedFetch it does not require a storage location — switching backends is exactly the moment the new backend has none yet — and it stays usable logged out, which the pre-login settings view needs. Two UI fixes for the same report: - A failed toggle now says why instead of silently snapping back. - Toggling pCloud on now starts the OAuth link rather than recording a backend the browser has no token for. Linking is the switch; its callback already records the backend. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011RYAzzVJJqrsp6TkeRS4vX
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
Fixes the report that "the Google Drive checkbox is stuck on and the pCloud checkbox won't check."
Root cause — predates the pCloud plugin
The storage backend is a per-user choice the server resolves from the request credentials (spec 007). But every frontend call to
/api/pluginsand/api/plugins/toggleused a barefetch()with no credentials attached, so the server could not tell who was asking:GET /api/pluginsfell back toDEFAULT_STORAGE_BACKEND→ JSON on Google Drive rendered active for everyone, regardless of their real choice.POST /api/plugins/togglereturned 401 for any storage plugin, andtogglePluginsilently reverted the checkbox → no storage backend could be selected from the UI at all.Reproduced against production before the fix:
Switching to Sheets was equally broken. pCloud was just the first backend switch anyone attempted since spec 007 landed.
Fix
pluginFetch()instorage.jsattaches credentials when present. UnlikeauthenticatedFetchit deliberately does not require a storage location — switching backends is precisely the moment the new backend has none yet — and it stays usable logged out, which the pre-login settings view renders. All 9 call sites converted.Two UI fixes for the same report:
Testing
node --checkon storage.js.Note the new tests pin the server contract, which was already correct — the defect was client-side. They guard against the endpoints silently losing per-user resolution, but the client wiring itself is verified by manual retest in production.
🤖 Generated with Claude Code
https://claude.ai/code/session_011RYAzzVJJqrsp6TkeRS4vX