fix workspace identity follow-ups in quota cleanup#86
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
|
@greptile @coderabbitai review |
|
✅ Actions performedReview triggered.
|
fix workspace identity follow-ups in quota cleanup
fix workspace identity follow-ups in quota cleanup
Summary
getWorkspaceIdentityKeyinside thetest/index.test.tsstorage mock so the PR no longer reintroduces identity drift in tests.test/storage.test.tscoverage for organization, account-only, and refresh-token fallback identity-key cases.Testing
npm run lintnpm test -- --run test/storage.test.ts test/index.test.tsNotes
test/storage.test.tsstill covers the concurrent flagged-write transaction path.note: greptile review for oc-chatgpt-multi-auth. cite files like
lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.Greptile Summary
this PR consolidates workspace identity logic by moving
getWorkspaceIdentityKeyfrom a privateindex.tsdefinition into an exported function inlib/storage.ts, then wiring bothnormalizeFlaggedStoragededup and theindex.tsupsert path through the same shared implementation. the test layer is updated to pull the real function viavi.importActualand the assertion style is migrated from spying onsaveFlaggedAccountsto inspecting the in-memory state afterwithFlaggedAccountStorageTransactioncompletes.changes:
lib/storage.ts: promotesgetWorkspaceIdentityKeyto a named export; movesnormalizeWorkspaceIdentityPartto module scope;normalizeFlaggedStoragedrops its local duplicate and the stale "more specific than active storage" commentindex.ts: removes the private identity-key definition; imports the shared export; no behavioral change tomatchesWorkspaceIdentityorupsertFlaggedAccountRecordtest/index.test.ts: async mock factory withvi.importActual; two assertion sites correctly moved towithFlaggedAccountStorageTransaction+ in-memory state; new integration test for org-scoped sibling workspace deactivationtest/storage.test.ts: newdescribe("getWorkspaceIdentityKey")unit block covering three branchesissues found:
organizationId-only branch (noaccountId) ofgetWorkspaceIdentityKeyhas no test case intest/storage.test.tstest/index.test.tsusesarrayContainingbut never asserts thatworkspace-liveis absent from flagged storage — a regression that flags both siblings would still passreturn {object inside the async mock factory is not indented relative toreturn, which differs from the rest of the file's styleloadFlaggedAccountsUnlocked, nor does it call out a regression test that exercises the concurrent flagged-write path under contention. the PR notes point to existing coverage intest/storage.test.ts, but that should be explicitly stated in the description per project conventionConfidence Score: 4/5
organizationId-only test branch and adding a negative assertion in the new integration test; no behavioral regression introducedtest/storage.test.ts(missing organizationId-only branch),test/index.test.ts(missing negative assertion + indentation in mock factory)Important Files Changed
getWorkspaceIdentityKeyto a module-level export and unifies flagged-storage dedup with active-cleanup identity logic;normalizeFlaggedStoragedrops its local duplicate and calls the shared function; logic is functionally identical to the removed codegetWorkspaceIdentityKeydefinition and imports the now-exported version fromlib/storage.ts;matchesWorkspaceIdentityandupsertFlaggedAccountRecordcontinue to call the same logic unchangedvi.mockfactory to async to import the realgetWorkspaceIdentityKey; migrates two assertion sites fromsaveFlaggedAccountsspy towithFlaggedAccountStorageTransaction+ in-memory state; adds a new integration test for org-scoped sibling workspace cleanup — missing a negative assertion thatworkspace-livestays out of flagged storage, and the return-object indentation inside the async factory is misalignedgetWorkspaceIdentityKey— three of four branches exercised; theorganizationId-only (no accountId) branch is untestedSequence Diagram
sequenceDiagram participant idx as index.ts (quota cleanup) participant storage as lib/storage.ts participant fs as Flagged-Accounts JSON idx->>storage: withFlaggedAccountStorageTransaction(cb) storage->>fs: readFile (locked via mutex) fs-->>storage: raw JSON storage->>storage: normalizeFlaggedStorage(data) storage->>storage: getWorkspaceIdentityKey(account) [shared] Note over storage: dedup by identity key<br/>(org+account | account | refreshToken) storage-->>idx: cb(loadedStorage, persist) idx->>idx: upsertFlaggedAccountRecord(accounts, deadRecord) idx->>idx: getWorkspaceIdentityKey(record) [same fn] idx->>storage: persist(nextStorage) storage->>fs: writeFile (atomic via mutex)Prompt To Fix All With AI
Last reviewed commit: "test: close pr86 gre..."
Context used: