feat(push): handle deleting custom types that still have documents#187
feat(push): handle deleting custom types that still have documents#187jomifepe wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 86370a7. Configure here.
|
|
||
| constructor(response: Response, body: unknown) { | ||
| super(response); | ||
| this.body = body; |
There was a problem hiding this comment.
BadRequestError body property is set but never read
Low Severity
The body property on BadRequestError is assigned in the constructor but never read anywhere in the codebase. The isDocumentsInUseError function — the only consumer of BadRequestError — calls error.text() (re-reading the response) instead of accessing error.body. This makes body dead code that adds confusion about the intended API.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 86370a7. Configure here.
| } | ||
|
|
||
| if (documentCount > DELETE_PAGES_LIMIT) { | ||
| const plural = documentCount === 1 ? "" : "s"; |
There was a problem hiding this comment.
This will always evaluate to "s" since DELETE_PAGES_LIMIT=200. I think we could skip it.
|
|
||
| if (documentCount === 0) { | ||
| try { | ||
| await removeCustomType(id, { repo, token, host }); |
There was a problem hiding this comment.
Is this retry necessary? How often does it help to recover from the error state? Maybe we could just throw error and prompt user to retry?


Summary
BadRequestError+ stable checks on the response body).POST …/core/documents/search(Editor parity:customTypes+limit: 0), enforce the 200 bulk-delete limit, then callDELETE …/core/documentswithcustomtype_idsbefore retrying type deletion.--delete-pagesopts in to cascading deletion of associated pages whenpushwould otherwise stop with an error;--forcealone does not enable that path (it still only skips dirty-repo checks and the “would delete remote models” guard).https://{repository}.{host}/builder/working?customTypes={id}.Note
Medium Risk
Adds automated bulk deletion of documents during
prismic pushwhen removing a custom type, which is potentially destructive and depends on new API calls and 400-error detection; guarded by an explicit--delete-pagesflag and a hard 200-document limit.Overview
prismic pushnow detects when a custom type deletion fails because it still has associated documents, and surfaces clearer guidance (including a deep link to the filtered working view).When this condition is hit, it queries the document total via
POST core/documents/search, enforces a 200-document bulk-delete cap, and—only with--delete-pages—cascades by callingDELETE core/documentsbefore retrying the type deletion.The request layer now throws a dedicated
BadRequestErroron HTTP 400 to support stable detection of the “documents in use” failure mode.Reviewed by Cursor Bugbot for commit 86370a7. Bugbot is set up for automated code reviews on this repo. Configure here.