{"record":{"id":"36ebdd6b4e6bc9ad","repo":"different-ai/openwork","slug":"collection-update-response-was-incomplete","errorCode":null,"errorMessage":"Collection update response was incomplete.","messagePattern":"Collection update response was incomplete\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/marketplace-data.tsx","lineNumber":484,"sourceCode":"  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();\n\n  return useMutation({\n    mutationFn: async (marketplaceId: string): Promise<string> => {\n      await runReauthableAction(\"delete-marketplace\", async () => {\n        const { response, payload } = await requestJson(","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/marketplace-data.tsx#L466-L502","documentation":"useUpdateMarketplace PATCHes /v1/marketplaces/{id} to rename or re-describe a marketplace collection. After a 2xx response the hook parses payload.item via parseMarketplace; if the body is not an object with an 'item' object (or parsing yields null), 'updated' stays null and this error is thrown. It means the server acknowledged the update but returned a body the client could not shape into a DenMarketplace.","triggerScenarios":"Server returns 200/204 with an empty body, a body without an 'item' key (e.g. returns the marketplace at top level, or {data:...}), or an item shape that parseMarketplace rejects (missing required fields), all with response.ok true.","commonSituations":"API version drift where the PATCH endpoint contract changed; a proxy/gateway stripping or rewriting response bodies; server bugs returning {ok:true} without the updated item; middleware that compresses/truncates JSON.","solutions":["Inspect the actual PATCH response body (devtools network tab) and confirm it contains { item: {...} }","Fix the server so PATCH /v1/marketplaces/:id returns the updated marketplace under 'item'","If the payload shape is legitimate (item at another key), update the client parse to read the correct key or extend parseMarketplace to accept it","Retry after confirming no gateway/middleware is mangling the JSON body"],"exampleFix":"// before\nupdated = isRecord(payload) && isRecord(payload.item) ? parseMarketplace(payload.item) : null;\n// after\nconst raw = isRecord(payload) && isRecord(payload.item) ? payload.item : isRecord(payload) ? payload : null;\nupdated = raw ? parseMarketplace(raw) : null;","handlingStrategy":"validation","validationCode":"function hasMarketplaceItem(payload: unknown): boolean {\n  return isRecord(payload) && isRecord(payload.item);\n}\n// after requestJson: if (!hasMarketplaceItem(payload)) log payload before treating update as done","typeGuard":"function isMarketplaceItem(v: unknown): v is Record<string, unknown> {\n  return isRecord(v) && typeof v.id === \"string\";\n}","tryCatchPattern":"try {\n  const updated = await updateMarketplace({ marketplaceId, name, description });\n} catch (err) {\n  if (err.message === \"Collection update response was incomplete.\") {\n    // server responded ok but body lacked {item}; surface a refresh prompt\n  }\n}","preventionTips":["Keep PATCH endpoints returning the updated resource under a stable 'item' key","Add a response-schema test for the marketplace PATCH route","Never let proxies rewrite JSON bodies; verify with integration tests"],"tags":["api","response-shape","react-query","marketplace"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}