Skip to content
This repository was archived by the owner on Mar 30, 2026. It is now read-only.

fix: stop manual projectId drift during account persistence#520

Open
chindris-mihai-alexandru wants to merge 1 commit intoNoeFabris:devfrom
chindris-mihai-alexandru:fix/projectid-regression-preserve-manual
Open

fix: stop manual projectId drift during account persistence#520
chindris-mihai-alexandru wants to merge 1 commit intoNoeFabris:devfrom
chindris-mihai-alexandru:fix/projectid-regression-preserve-manual

Conversation

@chindris-mihai-alexandru
Copy link
Copy Markdown
Contributor

Summary

  • preserve existing persisted projectId and managedProjectId values when merging account updates, so runtime/OAuth fallback values do not overwrite manual IDs
  • apply the same precedence in persistAccountPool and updateFromAuth to keep project IDs stable across login, token refresh, and rotation saves
  • regressions verified with full test/build run (npm run build, npm test)

Why

Manual project IDs in antigravity-accounts.json could be overwritten by auto-detected fallback values during normal runtime saves, causing permission errors for Gemini/Antigravity requests.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 610bbcc and 5ea8d23.

📒 Files selected for processing (3)
  • src/plugin.ts
  • src/plugin/accounts.ts
  • src/plugin/storage.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Greptile Review
🔇 Additional comments (3)
src/plugin/storage.ts (1)

154-158: Good precedence fix for manual project IDs.

This correctly preserves disk-stored projectId / managedProjectId during merge and prevents runtime fallback drift.

src/plugin/accounts.ts (1)

465-472: Update flow now consistently preserves manual IDs.

Nice change—updateFromAuth now follows disk-first precedence for project identifiers while still accepting fresh auth token parts.

src/plugin.ts (1)

316-326: Consistent merge precedence in persistence path.

This is the right fix in persistAccountPool: existing disk values now win for projectId fields, which keeps manual configuration stable across updates.


Walkthrough

The changes modify the account merge and update logic across three files to prioritize existing disk-stored project identifiers over new incoming values. In persistAccountPool, updateFromAuth, and mergeAccountStorage, the precedence for projectId and managedProjectId is inverted so that existing values are preserved when present, rather than being overwritten by new OAuth-fetched or in-memory values. This affects how accounts with matching emails and rotated tokens reconcile their stored identifiers.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: preventing manual projectId values from being overwritten during account persistence, which directly aligns with the changeset's core objective.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation behind preserving existing projectId and managedProjectId values across all three modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Feb 28, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • src/plugin.ts - No issues
  • src/plugin/accounts.ts - No issues
  • src/plugin/storage.ts - No issues

Overview

The PR correctly prioritizes existing (disk-loaded) projectId/managedProjectId values over OAuth-fetched or runtime values. This prevents auto-detected fallback IDs from overwriting manually configured project IDs.

Changes Summary

File Lines Changed Purpose
src/plugin.ts 325-326 Prioritize disk values in persistAccountPool
src/plugin/accounts.ts 471-472 Prioritize disk values in updateFromAuth
src/plugin/storage.ts 157-158 Prioritize disk values in mergeAccountStorage

The code is well-documented with clear comments explaining the intent, and the nullish coalescing operator (??) is used appropriately.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 28, 2026

Greptile Summary

This PR corrects the projectId preservation precedence across three merge/update paths. Previously, OAuth-fetched fallback values would overwrite manually configured projectId and managedProjectId values during account persistence, causing permission errors. The fix consistently prioritizes disk-persisted values over runtime values in persistAccountPool, updateFromAuth, and mergeAccountStorage.

  • Fixed precedence to prevent auto-detected fallbacks from overwriting manual configurations
  • Applied consistent pattern across all account merge operations
  • Completes fix from commit 4c47180 which had incorrect precedence and missed persistAccountPool

Confidence Score: 5/5

  • Safe to merge - targeted bug fix with consistent precedence changes
  • The changes are simple, focused, and solve a specific issue. The precedence flip (existing ?? incoming instead of incoming ?? existing) is applied consistently across all three merge/update locations. Comments clearly explain the intent, and existing tests pass per the PR description.
  • No files require special attention

Important Files Changed

Filename Overview
src/plugin.ts Flips precedence in persistAccountPool to preserve disk projectId/managedProjectId over OAuth values when updating existing accounts
src/plugin/accounts.ts Updates updateFromAuth to prioritize existing account projectId/managedProjectId over refresh token values
src/plugin/storage.ts Adjusts mergeAccountStorage to preserve disk projectId/managedProjectId over in-memory values during storage merge

Last reviewed commit: 5ea8d23

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant