Skip to content

fix(admin): report a completed workspace move's true source and its credentials - #7290

Merged
icecrasher321 merged 2 commits into
stagingfrom
fix/admin-move-recorded-source-and-credentials
Aug 30, 2026
Merged

fix(admin): report a completed workspace move's true source and its credentials#7290
icecrasher321 merged 2 commits into
stagingfrom
fix/admin-move-recorded-source-and-credentials

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

  • The durable workspace-move payload records sourceOrganizationId as a tri-state: an absent key means the operation predates the field, an explicit null means the workspace came from a personal source. The payload parser collapsed both to null with 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.
  • Both consumers now resolve through one helper that reports the origin as unknown only when the payload genuinely can't answer: no record, or a recorded id whose organization has since been deleted. The reload path splits its copy so a deleted organization no longer reads as an unpersisted one.
  • The applied and reloaded responses returned an empty credential summary. Unlike the source impact, those rows are workspace-scoped and travel with the move untouched — collectWorkspaceCredentialSummary already took a DbOrTx executor, 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, so backedBySourceOrgMember keeps its meaning.
  • That surfaced a follow-on: the applied path hardcoded credentials: 0 / environmentVariableKeys: 0 in its truncation record, which would now be wrong past the 1,000-row bound. buildAppliedTruncation merges the real counts the way preflight does, so a truncated applied review can't present as a complete one.

Type of Change

  • Bug fix

Testing

  • 5 new tests in 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

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…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.
@vercel

vercel Bot commented Aug 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 30, 2026 10:22pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR corrects completed workspace-move reporting by preserving the durable payload’s three source states and returning the workspace’s actual credential summary.

  • Distinguishes personal, missing, and deleted source organizations.
  • Collects credential metadata for applied, retried, and reloaded moves.
  • Includes dropped credential and environment-key counts in truncation metadata.
  • Adds regression coverage for source notices, credential summaries, retries, reloads, and truncation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

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]
Loading

Reviews (2): Last reviewed commit: "test(admin): cover the deleted source or..." | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 2 files

Confidence score: 4/5

  • apps/sim/lib/workspaces/admin-move.test.ts cannot exercise the deleted-organization reload path because the admin-move-source-impact mock 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.ts never exercises the buildAppliedTruncation credential 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

Comment thread apps/sim/lib/workspaces/admin-move.test.ts
Comment thread apps/sim/lib/workspaces/admin-move.test.ts
…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.
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic review

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 30, 2026

Copy link
Copy Markdown

@cubic review

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@icecrasher321
icecrasher321 merged commit faec125 into staging Aug 30, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant