fix(cloud-connection): reseed reports honest result instead of fake success#2172
Merged
Conversation
…uccess `POST /marketplace/install-local/:id/reseed-sample-data` ran the seed loader, which counts per-row write failures (locked DB, missing table, rejected validation) into `result.errors` rather than throwing. The handler only checked `mode === 'skipped'`, so a run that wrote ZERO rows still returned `success: true` AND flipped the install's `withSampleData` to true — the UI said "done" while the database stayed empty. Real-world trigger: a published template whose seed data drifted from its object schema (every row fails a required-field validation) → 38 errors, 0 rows, yet a green success toast and no data. Now: - 0 rows written ⇒ `422 reseed_no_rows`, with the first underlying error surfaced (e.g. "Validation failed: project_type (required)…") so the cause is actionable instead of hidden. - `withSampleData` only flips true once rows actually land. - partial success (some rows + some errors) still returns the error count. Adds `errorSample` to the seed summary and a focused test (`marketplace-install-local-reseed.test.ts`, 4 cases) covering all four paths. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 1 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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.
Problem
POST /api/v1/marketplace/install-local/:manifestId/reseed-sample-datacould reportsuccess: truewhile writing zero rows, and flip the install'swithSampleDataflag totrueregardless.The seed loader (
SeedLoaderService) runs row-by-row and counts write failures — a locked DB, a missing table, a rejected validation — intoresult.errorsinstead of throwing. The handler only bailed onseeded.mode === 'skipped', so an all-errors run looked like a success.Real-world trigger (found while debugging a showcase): the published
@objectlab/projecttemplate's seed data had drifted from its object schema — everypm_projectrow was missing the requiredproject_type/planned_end_date. Result:{ inserted: 0, updated: 0, errors: 38 }→ yet a green "re-seeded" toast and an empty database.Fix
In
handleReseed:422 reseed_no_rows, surfacing the first underlying error (e.g.Validation failed: project_type (required)…) so the cause is actionable.withSampleDataonly flipstrueonce rows actually land.applySideEffectsnow carries anerrorSample(first error message) in the seed summary.Tests
New
marketplace-install-local-reseed.test.ts(4 cases): zero-rows-with-errors → 422 + reason, zero-rows-no-errors → 422, rows-land → 200 + flag flips + ledger updated, partial → 200 + error count. All green; package builds clean (tsup + dts).Notes
fix/marketplace-sample-data.🤖 Generated with Claude Code