{"record":{"id":"64adcb67151864c7","repo":"different-ai/openwork","slug":"failed-to-update-collection-response-status","errorCode":null,"errorMessage":"Failed to update collection (${response.status}).","messagePattern":"Failed to update collection \\((.+?)\\)\\.","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/marketplace-data.tsx","lineNumber":479,"sourceCode":"\nexport function useUpdateMarketplace() {\n  const queryClient = useQueryClient();\n  const { runReauthableAction } = useOrgDashboard();\n\n  return useMutation({\n    mutationFn: async (input: { marketplaceId: string; name: string; description: string | null }): Promise<DenMarketplace> => {\n      let updated: DenMarketplace | null = null;\n      await runReauthableAction(\"update-marketplace\", async () => {\n        const { response, payload } = await requestJson(\n          `/v1/marketplaces/${encodeURIComponent(input.marketplaceId)}`,\n          {\n            method: \"PATCH\",\n            body: JSON.stringify({ name: input.name, description: input.description }),\n          },\n          15000,\n        );\n        if (!response.ok) {\n          throw getRequestError(payload, response, `Failed to update collection (${response.status}).`);\n        }\n        updated = isRecord(payload) && isRecord(payload.item) ? parseMarketplace(payload.item) : null;\n      });\n      if (!updated) {\n        throw new Error(\"Collection update response was incomplete.\");\n      }\n      return updated;\n    },\n    onSuccess: (marketplace) => {\n      queryClient.invalidateQueries({ queryKey: marketplaceQueryKeys.list() });\n      queryClient.invalidateQueries({ queryKey: marketplaceQueryKeys.resolved(marketplace.id) });\n    },\n  });\n}\n\nexport function useDeleteMarketplace() {\n  const queryClient = useQueryClient();\n  const { runReauthableAction } = useOrgDashboard();","sourceCodeStart":461,"sourceCodeEnd":497,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/marketplace-data.tsx#L461-L497","documentation":"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.","triggerScenarios":"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.","commonSituations":"Another admin deleted the collection while it was being edited (stale cache); renamed to a duplicate name; expired session; role lacks edit rights.","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."],"exampleFix":"// before\nawait updateMarketplace({ id, name, description });\n// after\ntry {\n  await updateMarketplace({ id, name, description });\n} catch (err) {\n  if (isReauthRequiredError(err)) { startReauth(); }\n  else if (/\\(404\\)/.test(err.message)) { await refetchMarketplaces(); }\n  else setUpdateError(err.message);\n}","handlingStrategy":"try-catch","validationCode":"// before updateMarketplace\nif (!marketplaceId) throw new Error(\"Missing collection id\");\nif (!input.name?.trim()) throw new Error(\"Collection name is required\");","typeGuard":"function isNotFoundError(err: unknown): boolean {\n  return err instanceof Error && /\\(404\\)/.test(err.message);\n}","tryCatchPattern":"try {\n  await updateMarketplace(input);\n} catch (err) {\n  if (isReauthRequiredError(err)) startReauth();\n  else if (isNotFoundError(err)) { await refetchMarketplaces(); }\n  else setFormError(err.message);\n}","preventionTips":["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"],"tags":["http","den-api","marketplace"],"backgroundTag":"http-request-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}