different-ai/openwork · error · Error
Failed to update collection (${response.status}).
Error message
Failed to update collection (${response.status}). What it means
Thrown by useUpdateMarketplace when the PATCH that updates a collection's name/description returns a non-ok status. getRequestError surfaces the server's error message or the fallback 'Failed to update collection (<status>)'. It means the server rejected the update before the response could be parsed into a marketplace item.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/marketplace-data.tsx:479
export function useUpdateMarketplace() {
const queryClient = useQueryClient();
const { runReauthableAction } = useOrgDashboard();
return useMutation({
mutationFn: async (input: { marketplaceId: string; name: string; description: string | null }): Promise<DenMarketplace> => {
let updated: DenMarketplace | null = null;
await runReauthableAction("update-marketplace", async () => {
const { response, payload } = await requestJson(
`/v1/marketplaces/${encodeURIComponent(input.marketplaceId)}`,
{
method: "PATCH",
body: JSON.stringify({ name: input.name, description: input.description }),
},
15000,
);
if (!response.ok) {
throw getRequestError(payload, response, `Failed to update collection (${response.status}).`);
}
updated = isRecord(payload) && isRecord(payload.item) ? parseMarketplace(payload.item) : null;
});
if (!updated) {
throw new Error("Collection update response was incomplete.");
}
return updated;
},
onSuccess: (marketplace) => {
queryClient.invalidateQueries({ queryKey: marketplaceQueryKeys.list() });
queryClient.invalidateQueries({ queryKey: marketplaceQueryKeys.resolved(marketplace.id) });
},
});
}
export function useDeleteMarketplace() {
const queryClient = useQueryClient();
const { runReauthableAction } = useOrgDashboard();View on GitHub (pinned to 2b7df46e8a)
Solutions
- For 404, refresh the marketplace list (invalidate queries) and inform the user the collection is gone.
- For 401/403, re-authenticate or acquire edit permission for the org.
- For 400/409/422, correct the name/description (duplicates, validation limits) and retry.
- For 5xx, retry with backoff and check server logs.
- Route isReauthRequiredError into the re-auth flow.
Example fix
// before
await updateMarketplace({ id, name, description });
// after
try {
await updateMarketplace({ id, name, description });
} catch (err) {
if (isReauthRequiredError(err)) { startReauth(); }
else if (/\(404\)/.test(err.message)) { await refetchMarketplaces(); }
else setUpdateError(err.message);
} Defensive patterns
Strategy: try-catch
Validate before calling
// before updateMarketplace
if (!marketplaceId) throw new Error("Missing collection id");
if (!input.name?.trim()) throw new Error("Collection name is required"); Type guard
function isNotFoundError(err: unknown): boolean {
return err instanceof Error && /\(404\)/.test(err.message);
} Try / catch
try {
await updateMarketplace(input);
} catch (err) {
if (isReauthRequiredError(err)) startReauth();
else if (isNotFoundError(err)) { await refetchMarketplaces(); }
else setFormError(err.message);
} Prevention
- Invalidate marketplace queries after external deletes so stale rows are not edited
- Re-check name uniqueness before PATCH
- Confirm the user still has edit rights before opening the edit form
- Retry 5xx once with backoff before showing an error
When it happens
Trigger: Non-ok response from PATCH /v1/marketplaces/:id (15000ms timeout): 404 when the marketplace id no longer exists (deleted elsewhere), 401/403 when the session or permissions are insufficient, 400/422 for invalid name/description, 409 for name conflicts, 5xx on server errors.
Common situations: Another admin deleted the collection while it was being edited (stale cache); renamed to a duplicate name; expired session; role lacks edit rights.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Failed to grant access (${response.status}).
- Failed to revoke access (${response.status}).
- Failed to create collection (${response.status}).
- Failed to delete collection (${response.status}).
- invalid_marketplace_payload
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/64adcb67151864c7.
Report an issue: GitHub.