Skip to content

fix(cloud-connection): reseed reports honest result instead of fake success#2172

Merged
os-zhuang merged 1 commit into
mainfrom
fix/reseed-honest-result
Jun 22, 2026
Merged

fix(cloud-connection): reseed reports honest result instead of fake success#2172
os-zhuang merged 1 commit into
mainfrom
fix/reseed-honest-result

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Problem

POST /api/v1/marketplace/install-local/:manifestId/reseed-sample-data could report success: true while writing zero rows, and flip the install's withSampleData flag to true regardless.

The seed loader (SeedLoaderService) runs row-by-row and counts write failures — a locked DB, a missing table, a rejected validation — into result.errors instead of throwing. The handler only bailed on seeded.mode === 'skipped', so an all-errors run looked like a success.

Real-world trigger (found while debugging a showcase): the published @objectlab/project template's seed data had drifted from its object schema — every pm_project row was missing the required project_type / planned_end_date. Result: { inserted: 0, updated: 0, errors: 38 } → yet a green "re-seeded" toast and an empty database.

Fix

In handleReseed:

  • 0 rows written ⇒ 422 reseed_no_rows, surfacing the first underlying error (e.g. Validation failed: project_type (required)…) so the cause is actionable.
  • withSampleData only flips true once rows actually land.
  • Partial success (some rows + some errors) still succeeds but reports the error count.

applySideEffects now carries an errorSample (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

  • Behaviour-compatible for the normal case (rows seed → success as before).
  • The matching console-side change (surface the error, stop showing a success toast on 0 rows) is in objectui fix/marketplace-sample-data.

🤖 Generated with Claude Code

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

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
spec Building Building Preview, Comment Jun 22, 2026 5:06am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/cloud-connection.

1 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/concepts/cloud-artifact-api.mdx (via packages/cloud-connection)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@os-zhuang
os-zhuang merged commit 688cfb4 into main Jun 22, 2026
15 of 16 checks passed
@os-zhuang
os-zhuang deleted the fix/reseed-honest-result branch June 22, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants