Skip to content

Commit fe48d21

Browse files
committed
fix: map integration link guard to API v2 conflicts
The v2 item and workspace delete routes replaced the internal handlers that translated the protected-link guard into HTTP 409. Without a mapping the guard surfaced as a 500, so both error funnels now return the same conflict response as the v1 handlers.
1 parent 5b92692 commit fe48d21

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

internal/restapi/v2/items.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,9 @@ func itemError(err error) error {
715715
if errors.Is(err, services.ErrItemTypeMigrationRequired) {
716716
return newError(http.StatusConflict, "migration_required", err.Error())
717717
}
718+
if errors.Is(err, services.ErrItemHasProtectedIntegrationLinks) {
719+
return newError(http.StatusConflict, "conflict", "Remove all protected integration links from the affected items before deleting them.")
720+
}
718721
if errors.Is(err, services.ErrBulkItemNotFound) {
719722
return newError(http.StatusNotFound, "not_found", "Item not found")
720723
}

internal/restapi/v2/scoped_catalog.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ func workspaceMutationError(err error) error {
261261
return newError(http.StatusBadRequest, "invalid_request", err.Error())
262262
case errors.Is(err, repository.ErrDuplicateEntry):
263263
return newError(http.StatusConflict, "conflict", "Workspace key already exists")
264+
case errors.Is(err, services.ErrWorkspaceHasProtectedIntegrationLinks):
265+
return newError(http.StatusConflict, "conflict", "Remove all protected integration links from this workspace before deleting it.")
264266
case errors.Is(err, services.ErrInvalidWorkspaceTemplate), errors.Is(err, services.ErrWorkspaceTemplateTooLarge), errors.Is(err, services.ErrPersonalWorkspaceTemplate):
265267
return newError(http.StatusUnprocessableEntity, "unprocessable_entity", err.Error())
266268
default:

0 commit comments

Comments
 (0)