different-ai/openwork · error

Collection update response was incomplete.

Error message

Collection update response was incomplete.

What it means

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.

Source

Thrown at ee/apps/den-web/app/(den)/dashboard/_components/marketplace-data.tsx:484

  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();

  return useMutation({
    mutationFn: async (marketplaceId: string): Promise<string> => {
      await runReauthableAction("delete-marketplace", async () => {
        const { response, payload } = await requestJson(

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Inspect the actual PATCH response body (devtools network tab) and confirm it contains { item: {...} }
  2. Fix the server so PATCH /v1/marketplaces/:id returns the updated marketplace under 'item'
  3. 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
  4. Retry after confirming no gateway/middleware is mangling the JSON body

Example fix

// before
updated = isRecord(payload) && isRecord(payload.item) ? parseMarketplace(payload.item) : null;
// after
const raw = isRecord(payload) && isRecord(payload.item) ? payload.item : isRecord(payload) ? payload : null;
updated = raw ? parseMarketplace(raw) : null;
Defensive patterns

Strategy: validation

Validate before calling

function hasMarketplaceItem(payload: unknown): boolean {
  return isRecord(payload) && isRecord(payload.item);
}
// after requestJson: if (!hasMarketplaceItem(payload)) log payload before treating update as done

Type guard

function isMarketplaceItem(v: unknown): v is Record<string, unknown> {
  return isRecord(v) && typeof v.id === "string";
}

Try / catch

try {
  const updated = await updateMarketplace({ marketplaceId, name, description });
} catch (err) {
  if (err.message === "Collection update response was incomplete.") {
    // server responded ok but body lacked {item}; surface a refresh prompt
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/36ebdd6b4e6bc9ad. Report an issue: GitHub.