Skip to content

feat(push): handle delete custom type with documents#187

Merged
jomifepe merged 10 commits into
mainfrom
jp/delete-ct
May 21, 2026
Merged

feat(push): handle delete custom type with documents#187
jomifepe merged 10 commits into
mainfrom
jp/delete-ct

Conversation

@jomifepe
Copy link
Copy Markdown
Contributor

@jomifepe jomifepe commented May 18, 2026

Summary

  • Detect Custom Types API 400 responses when deleting a type that still has documents (BadRequestError + stable checks on the response body).
  • Resolve document counts via POST …/core/documents/search (Editor parity: customTypes + limit: 0), enforce the 200 bulk-delete limit, then call DELETE …/core/documents with customtype_ids before retrying type deletion.
  • Errors include a deep link to the filtered builder working view: https://{repository}.{host}/builder/working?customTypes={id}.

Note

Medium Risk
Moderate risk: changes prismic push delete behavior and introduces new 400-error handling in the shared request helper, which could affect other callers’ error paths.

Overview
prismic push now wraps custom type deletions with additional handling: if the delete fails due to associated documents, it queries the document count and throws a clearer CommandError instructing the user to delete documents first, including deep links to the filtered working view and the custom type list.

To support this, the core client adds getDocumentTotalByCustomTypes() (via POST core/documents/search with limit: 0), Wroom adds URL builders for the working view and type lists, and the shared request() utility now throws a dedicated BadRequestError on HTTP 400 for more reliable detection.

Reviewed by Cursor Bugbot for commit 32ac787. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread src/commands/push.ts Outdated
Comment thread src/lib/request.ts
Comment thread src/commands/push.ts
@jomifepe jomifepe self-assigned this May 18, 2026
Comment thread src/lib/request.ts
Comment thread src/commands/push.ts Outdated
Comment thread src/commands/push.ts Outdated
jomifepe and others added 2 commits May 21, 2026 11:21
Remove the ability to cascade-delete documents when removing a custom
type. The CLI now always blocks and directs users to delete pages
manually, eliminating the risk of irrecoverable data loss from AI agents
or accidental usage in production.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 28c4453. Configure here.

Comment thread src/commands/push.ts
Comment thread src/commands/push.ts Outdated
Co-authored-by: Cursor <cursoragent@cursor.com>
@jomifepe jomifepe changed the title feat(push): handle deleting custom types that still have documents feat(push): catch deleting custom types with documents response May 21, 2026
@jomifepe jomifepe changed the title feat(push): catch deleting custom types with documents response feat(push): catch delete custom type with documents response May 21, 2026
@jomifepe jomifepe changed the title feat(push): catch delete custom type with documents response feat(push): handle delete custom type with documents May 21, 2026
@jomifepe jomifepe merged commit 8218fba into main May 21, 2026
16 checks passed
@jomifepe jomifepe deleted the jp/delete-ct branch May 21, 2026 15:04
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