Skip to content

fix(seed): chunk IdP user truncation and skip already-deleted users - #2197

Merged
toiroakr merged 8 commits into
mainfrom
fix/seed-idp-truncate-chunking
Aug 31, 2026
Merged

fix(seed): chunk IdP user truncation and skip already-deleted users#2197
toiroakr merged 8 commits into
mainfrom
fix/seed-idp-truncate-chunking

Conversation

@dqn

@dqn dqn commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary

tailor seed apply --truncate no longer fails with deadline_exceeded once the IdP holds more than a few dozen _User records, and a user that is listed but already gone by the time it is deleted no longer fails every run.

After

Truncating _User via tailor.idp.Client...
  Found 60 IDP users to delete
  Deleting 60 _User records...
  Split into 3 chunks
  Chunk 1/3: 25 users
  [_User] Deleted 1/60: playwright-1@example.com
  ...
  [_User] Already deleted 42/60: playwright-42@example.com
  ...
  ✓ _User: 59 users deleted, 1 already deleted

When a chunk still fails (for example permission denied), the run reports the confirmed counts as a warning and exits non-zero; re-running is safe because already-deleted users are skipped.

Affected surfaces

  • SeedIdpUserContext (@tailor-platform/sdk/cli): new required listScriptCode; truncateScriptCode now deletes the { users, offset, total } chunk it receives, and still lists and deletes every user when called without input.

Notes

  • Already-published @tailor-platform/sdk-plugin-seed 0.2.x keeps working with this sdk through that no-input fallback. The reverse pairing (new plugin, older sdk) fails early asking to update the sdk.
  • permission denied on delete still fails the run; it is a server-side authorization decision and out of scope here.

dqn added 6 commits August 29, 2026 15:01
`tailor seed apply --truncate` deleted every IdP `_User` record inside a
single TestExecScript call, so a few dozen users were enough to exceed the
operator API deadline, and a user that was listed but gone by delete time
failed the run on every retry.

Split truncation into a listing script and a delete script that receives one
chunk of 25 users per call, mirroring the `_User` upsert path, and count a
"not found" delete as already deleted so truncation is idempotent.
…ially fails

Also drop the derivable `total` from the listing script result.
…ugins

Published seed plugins run the truncate script without input, so fall back
to listing and deleting every user when no chunk is passed. Match only
"user not found" when treating a delete as already done, since the gRPC
code text of every NotFound error also contains "not found", and fail
early with a clear message when the installed sdk lacks the listing script.
@changeset-bot

changeset-bot Bot commented Aug 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1303d70

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@tailor-platform/sdk Minor
@tailor-platform/sdk-plugin-seed Major
@tailor-platform/sdk-plugin-setup Major
@tailor-platform/sdk-plugin-tailordb-erd Major
@tailor-platform/create-sdk Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Aug 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

@tailor-platform/create-sdk

pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/create-sdk@1303d70

@tailor-platform/eslint-plugin-sdk

pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/eslint-plugin-sdk@1303d70

@tailor-platform/sdk

pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/sdk@1303d70

@tailor-platform/sdk-plugin-seed

pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/sdk-plugin-seed@1303d70

@tailor-platform/sdk-plugin-setup

pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/sdk-plugin-setup@1303d70

@tailor-platform/sdk-plugin-tailordb-erd

pnpm add https://pkg.pr.new/tailor-platform/sdk/@tailor-platform/sdk-plugin-tailordb-erd@1303d70

commit: 1303d70

@github-actions

This comment has been minimized.

@dqn
dqn marked this pull request as ready for review August 29, 2026 09:28
@dqn
dqn requested a review from a team as a code owner August 29, 2026 09:28
@dqn
dqn requested a review from toiroakr August 29, 2026 09:28
github-actions[bot]

This comment was marked as off-topic.

Comment thread packages/sdk-plugin-seed/src/apply.ts
@toiroakr toiroakr assigned dqn and unassigned toiroakr Aug 29, 2026
@github-actions

This comment has been minimized.

@dqn
dqn requested a review from toiroakr August 30, 2026 02:59
@dqn dqn assigned toiroakr and unassigned dqn Aug 30, 2026
@toiroakr toiroakr assigned dqn and unassigned toiroakr Aug 30, 2026
Comment thread packages/sdk-plugin-seed/src/apply.ts
@github-actions

Copy link
Copy Markdown

Code Metrics Report (packages/sdk)

main (c4da7c8) #2197 (3acc9b3) +/-
Coverage 81.5% 81.5% +0.0%
Code to Test Ratio 1:0.5 1:0.5 +0.0
Details
  |                    | main (c4da7c8) | #2197 (3acc9b3) |  +/-  |
  |--------------------|----------------|-----------------|-------|
+ | Coverage           |          81.5% |           81.5% | +0.0% |
  |   Files            |            502 |             502 |     0 |
  |   Lines            |          19742 |           19744 |    +2 |
+ |   Covered          |          16107 |           16109 |    +2 |
+ | Code to Test Ratio |          1:0.5 |           1:0.5 |  +0.0 |
  |   Code             |         147588 |          147745 |  +157 |
+ |   Test             |          75733 |           75858 |  +125 |

Code coverage of files in pull request scope (100.0% → 100.0%)

Files Coverage +/- Status
packages/sdk/src/cli/shared/seed-context.ts 100.0% 0.0% modified
packages/sdk/src/plugin/builtin/seed/idp-user-processor.ts 100.0% 0.0% modified

SDK Configure Bundle Size

main (c4da7c8) #2197 (3acc9b3) +/-
configure-index-size 13.29KB 13.29KB 0KB
dependency-chunks-size 13.17KB 13.17KB 0KB
total-bundle-size 26.46KB 26.46KB 0KB

Runtime Performance

main (c4da7c8) #2197 (3acc9b3) +/-
Generate Median 2,299ms 2,284ms -15ms
Generate Max 2,313ms 2,309ms -4ms
Apply Build Median 2,458ms 2,432ms -26ms
Apply Build Max 2,483ms 2,464ms -19ms

Type Performance (instantiations)

main (c4da7c8) #2197 (3acc9b3) +/-
tailordb-basic 45,029 45,029 0
tailordb-optional 4,758 4,758 0
tailordb-relation 3,972 3,972 0
tailordb-validate 684 684 0
tailordb-hooks 5,823 5,823 0
tailordb-object 13,752 13,752 0
tailordb-enum 1,609 1,609 0
resolver-basic 12,120 12,120 0
resolver-nested 35,419 35,419 0
resolver-array 24,056 24,056 0
executor-schedule 4,489 4,489 0
executor-webhook 1,130 1,130 0
executor-record 4,585 4,585 0
executor-resolver 5,808 5,808 0
executor-operation-function 1,118 1,118 0
executor-operation-gql 1,126 1,126 0
executor-operation-webhook 1,137 1,137 0
executor-operation-workflow 1,931 1,931 0

Reported by octocov

@dqn
dqn requested a review from toiroakr August 30, 2026 09:13
@dqn dqn assigned toiroakr and unassigned dqn Aug 30, 2026

This comment was marked as off-topic.

@toiroakr toiroakr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@toiroakr
toiroakr merged commit 7672840 into main Aug 31, 2026
47 checks passed
@toiroakr
toiroakr deleted the fix/seed-idp-truncate-chunking branch August 31, 2026 00:19
This was referenced Aug 31, 2026
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.

3 participants