fix(admin): report a completed workspace move's true source and its credentials - #7290
Merged
icecrasher321 merged 2 commits intoAug 30, 2026
Merged
Conversation
…redentials The durable move payload records `sourceOrganizationId` as a tri-state: absent means the operation predates the field, an explicit `null` means the workspace came from a personal source. The payload parser collapsed both to `null`, so every reload or retry of a personal-source move claimed its source organization had failed to persist. The applied and reloaded responses also blanked the credential summary. Unlike the source impact, those rows are workspace-scoped and travel with the move untouched, so an admin who had just confirmed a move was told the workspace carried no secrets, environment variables, or BYOK keys.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Greptile SummaryThe PR corrects completed workspace-move reporting by preserving the durable payload’s three source states and returning the workspace’s actual credential summary.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/workspaces/admin-move.ts | Preserves tri-state source provenance, centralizes source resolution, and reports credential and truncation data across completed-move paths without an accepted follow-up defect. |
| apps/sim/lib/workspaces/admin-move.test.ts | Adds focused regression tests for personal, legacy, and deleted sources plus applied, retried, reloaded, and truncated credential summaries. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
Payload[Completed move payload] --> Present{sourceOrganizationId key present?}
Present -->|No| Legacy[Source unknown]
Present -->|Yes, null| Personal[Personal source]
Present -->|Yes, organization ID| Resolve[Resolve source organization]
Resolve -->|Found| Organization[Named organization source]
Resolve -->|Deleted| Deleted[Source unknown: deleted]
Legacy --> Summary[Build completed-move summary]
Personal --> Summary
Organization --> Summary
Deleted --> Summary
Credentials[Collect workspace credential summary] --> Summary
Summary --> Truncation[Merge credential truncation counts]
Truncation --> Response[Applied, retried, or reloaded response]
Reviews (2): Last reviewed commit: "test(admin): cover the deleted source or..." | Re-trigger Greptile
There was a problem hiding this comment.
2 issues found across 2 files
Confidence score: 4/5
apps/sim/lib/workspaces/admin-move.test.tscannot exercise the deleted-organization reload path because theadmin-move-source-impactmock hardcodes the relevant state, leaving the new user-facing fallback unverified; make the mock configurable and add coverage for that branch.apps/sim/lib/workspaces/admin-move.test.tsnever exercises thebuildAppliedTruncationcredential or environment-variable counts because fixtures hardcode both truncation fields to zero, so regressions in the applied-truncation fix could go unnoticed; add fixtures with nonzero counts.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/workspaces/admin-move.test.ts">
<violation number="1" location="apps/sim/lib/workspaces/admin-move.test.ts:859">
P2: The deleted-organization reload branch announced in the PR ('The organization this workspace came from has since been deleted...') has no test, and it cannot be exercised: the admin-move-source-impact mock hardcodes getSourceOrganization to always resolve org-source and doesn't expose it for per-test override. Add a case where sourceOrganizationId is recorded but getSourceOrganization resolves null, and assert the 'since been deleted' notice, to protect the tri-state fix against regression.</violation>
<violation number="2" location="apps/sim/lib/workspaces/admin-move.test.ts:901">
P3: The applied-truncation fix (merging real credential/environmentVariableKey counts in buildAppliedTruncation) is never exercised: all test fixtures hardcode truncatedCredentials:0 / truncatedEnvironmentVariableKeys:0, so a regression to hardcoded zeros would go undetected. Add a case with non-zero truncated counts (e.g. POPULATED with truncatedCredentials:1) and assert the applied/reloaded summary's truncated.credentials is propagated.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…ential counts `getSourceOrganization` was mocked inline in the module factory, so the reload branch that reports a recorded-but-deleted source organization could not be exercised at all. Hoist it like the other mocks and pin that third tri-state. Every credential fixture also reported zero dropped rows, so the applied and reloaded truncation records would not have caught a regression to the hardcoded zeros they replaced.
Collaborator
Author
Collaborator
Author
|
@cubic review |
@icecrasher321 I have started the AI code review. It will take a few minutes to complete. |
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
sourceOrganizationIdas a tri-state: an absent key means the operation predates the field, an explicitnullmeans the workspace came from a personal source. The payload parser collapsed both tonullwith a?? null, so every reload or retry of a personal-source move emitted a notice claiming its source organization had failed to persist — the record was complete, there was simply no organization to name.collectWorkspaceCredentialSummaryalready took aDbOrTxexecutor, so nothing forced the blank. An admin who had just confirmed a move was told the workspace carried no credentials, environment variables, or BYOK keys. All three applied sites now collect it against the pre-move source organization, sobackedBySourceOrgMemberkeeps its meaning.credentials: 0/environmentVariableKeys: 0in its truncation record, which would now be wrong past the 1,000-row bound.buildAppliedTruncationmerges the real counts the way preflight does, so a truncated applied review can't present as a complete one.Type of Change
Testing
admin-move.test.ts. Reverting the source fix and re-running confirms 4 of them fail against the old code (false notice on a personal source; missing credentials on reload, on confirm, and on retry). The 5th pins the legitimate legacy-payload warning and passes both ways — that path is unchanged.bun run test lib/workspaces/ lib/admin/— 251 passed.bun run type-check,bun run lint,bun run check:audits(39 audits incl.check:api-validation:strict) all pass.Checklist