fix(plugins): keep a plugin's tokens and local files across store updates - #755
Open
ChuckBuilds wants to merge 5 commits into
Open
ChuckBuilds wants to merge 5 commits into
ChuckBuilds wants to merge 5 commits into
Conversation
…ates A monorepo plugin update replaces the plugin directory with the fresh download and deletes the old copy, taking with it everything the plugin wrote beside itself. On 2026-10-04 updating calendar 1.2.9 -> 1.2.12 deleted token.pickle and credentials.json, and the calendar stopped until they were restored from a backup. Before the set-aside copy is discarded (store update, reinstall over an existing copy, install_from_url replace), carry over files the plugin's .gitignore excludes plus known secret/state files (*.pickle, token.json, credentials.json, config_secrets.json, .pkce_code_verifier). Files the new release ships win; byte code and .git are not carried; if a copy fails the old copy is kept. The git-pull path no longer sweeps untracked tokens into its auto-stash, which is never popped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gin does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 24 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 56 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
TestARestoreWithNothingToResume took the last cache_manager.set call to be the on-demand state, but the controller's font-usage publisher thread writes font_usage_snapshot to the same mock, and on a slow runner it lands last. Failing on main since #748 (Python 3.11 job). Same fix for the named-mode restart test, which had the same race. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fix/plugin-update-keeps-local-files # Conflicts: # test/test_on_demand_live_and_restore.py
…equest TestPixletEditorHostDefaultsButDoesNotOverride patched subprocess.Popen for the whole request. When the captive-portal before_request hook's 30s AP-mode cache had expired, its `systemctl is-active hostapd` check went through subprocess.run, got the fake process, and raised TypeError (run() uses the process as a context manager): a 500 instead of 200. Seen on the Python 3.13 job; reproduced locally by forcing the cache to expire. Other calls now reach the real Popen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
On 2026-10-04, updating
calendar1.2.9 → 1.2.12 from the web UI (POST /api/v3/plugins/update) deletedplugin-repos/calendar/token.pickleandcredentials.json, the plugin's Google OAuth files. The hot reload logged "Credentials file not found", and the calendar stayed broken until the files were restored from a backup.The cause: a monorepo plugin update renames the old directory aside, downloads the new release and then deletes the old copy. No release contains files the plugin writes at runtime, so they went with it.
Fix
Directory-swap paths (
_discard_backupinstore_install.py): before the set-aside copy is deleted, the plugin's own local files are copied into the new copy. Those are:.gitignoreexcludes (old copy's or new copy's), andtoken.pickle,*.pickle,token.json,credentials.json,config_secrets.json,.pkce_code_verifier.A file the new release ships is never overwritten.
__pycache__,*.pycand.gitare not carried over. If a copy fails, the old copy is kept rather than deleted, and the log names its path.This covers every place an existing install is replaced:
_reinstall_with_rollback(routine store update and old-remote → monorepo migration),install_pluginover an existing copy, andinstall_from_urlreplacing an existing copy. The new copy is found with_existing_install(), so a registry id that differs from the install directory still resolves.Plugins installed from their own git repo: gitignored files were already safe there. But
git stash push -uswept untracked, non-ignored files into an auto-stash that is never popped, so a token the repo forgot to gitignore disappeared. The stash now excludes the known secret files via:(exclude,glob)pathspecs, and those files alone no longer trigger a stash.The rules live in the new
src/plugin_system/plugin_local_files.py, which has a small.gitignorematcher (pathspecisn't a dependency).Tests
test/test_store_update_keeps_local_files.py:token.pickle,credentials.jsonand a gitignoredcache/events.json, runupdate_plugin, check all three survive and no backup is left behind.gitignoreinstall_from_urlreplacing onegit pull, with an untracked, non-ignored token; a token alone does not create a stash.gitignorerulesOn the pre-fix store code, 6 of these fail (the "release content wins" guard passes either way). They pass on Windows and on ledpi (Linux, git 2.47). The store, update, install and web-interface tests show the same 38 pre-existing Windows-only failures before and after (
test_install_lowmemneeds bash, the starlark routes needfcntl).🤖 Generated with Claude Code