{"record":{"id":"4f5064369e34ffec","repo":"can1357/oh-my-pi","slug":"plik-file-response-did-not-include-an-id","errorCode":null,"errorMessage":"plik file response did not include an id","messagePattern":"plik file response did not include an id","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/blob-broker/uploaders-self-hosted.ts","lineNumber":497,"sourceCode":"\t\t\t\t\t\tremovable,\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t\t\"plik\",\n\t\t\t);\n\t\t\tconst metadata = plikUpload(await metadataResponse.json());\n\t\t\tconst uploadId = metadata.id;\n\t\t\tconst uploadToken = metadata.uploadToken;\n\t\t\tconst fileResponse = await expectOk(\n\t\t\t\tawait requestFetch(endpoint(base, \"file\", uploadId), {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\theaders: { \"X-UploadToken\": uploadToken },\n\t\t\t\t\tbody: multipartFile(request),\n\t\t\t\t}),\n\t\t\t\t\"plik\",\n\t\t\t);\n\t\t\tconst fileBody: unknown = await fileResponse.json();\n\t\t\tconst file = plikFile(fileBody);\n\t\t\tif (!file) throw new Error(\"plik file response did not include an id\");\n\t\t\tconst fileId = file.id;\n\t\t\tconst remoteName = file.name ?? filename;\n\t\t\tconst downloadBase = metadata.downloadBase ?? base;\n\t\t\tconst url = endpoint(downloadBase, \"file\", uploadId, fileId, remoteName);\n\t\t\tconst deleteAction: RemoteDeleteAction = {\n\t\t\t\tmethod: \"DELETE\",\n\t\t\t\turl: endpoint(base, \"upload\", uploadId),\n\t\t\t\theaders: { \"X-UploadToken\": uploadToken },\n\t\t\t};\n\t\t\tconst expiresAt = ttlSeconds !== undefined && ttlSeconds > 0 ? Date.now() + ttlSeconds * 1_000 : undefined;\n\t\t\treturn publication(\"plik\", request, url, {\n\t\t\t\t...(expiresAt === undefined ? {} : { expiresAt }),\n\t\t\t\tdelete: deleteAction,\n\t\t\t\tremoteId: uploadId,\n\t\t\t});\n\t\t},\n\t};\n}","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/blob-broker/uploaders-self-hosted.ts#L479-L515","documentation":"The Plik uploader parses the JSON response of the file-upload request through plikFile(), which only succeeds if the body contains an id field. Without an id the per-file download URL cannot be constructed, so the upload aborts with this error. It indicates the Plik server answered, but not with the expected file object.","triggerScenarios":"POST of the multipart upload to the Plik server returns 2xx but the JSON body either is not a file object (e.g. an error object, a null, or a missing id) — typically because the server rejected the upload token/ttl settings but still returned 200, or because the endpoint URL points at a non-Plik service.","commonSituations":"Pointing the plik base URL at a wrong path or a compatible-but-different service; a Plik server with upload tokens required returning {error: ...}; proxy or auth middleware returning an HTML/JSON page that is not a Plik file response.","solutions":["Verify the Plik server URL and that POST <base>/file returns a JSON object with an id (test with curl)","Check for an error field in the response body (Plik may reject token/ttl settings with 200/error payloads)","Confirm the server version matches the expected Plik API shape","Check auth/proxy middleware isn't intercepting the upload request"],"exampleFix":"// before\nconst file = plikFile(fileBody);\nif (!file) throw new Error(\"plik file response did not include an id\");\n// after: surface server error for diagnosis\nconst file = plikFile(fileBody);\nif (!file) throw new Error(`plik file response did not include an id: ${JSON.stringify(fileBody).slice(0, 300)}`);","handlingStrategy":"type-guard","validationCode":"const body = await fileResponse.json();\nif (typeof body !== \"object\" || body === null || !(\"id\" in body)) {\n\tthrow new Error(`Plik returned unexpected payload: ${JSON.stringify(body).slice(0, 200)}`);\n}","typeGuard":"function isPlikFile(v: unknown): v is { id: string; name?: string } {\n\treturn typeof v === \"object\" && v !== null && typeof (v as { id?: unknown }).id === \"string\";\n}","tryCatchPattern":"try {\n\tawait uploader.upload(req);\n} catch (err) {\n\tif (err instanceof Error && err.message.includes(\"plik file response\")) {\n\t\t// log raw response body; check Plik server URL and error field\n\t}\n\tthrow err;\n}","preventionTips":["Confirm the Plik base URL points at the actual Plik API root","Test POST <base>/file with curl and inspect the JSON for an id field","Check for error fields in Plik responses (token/ttl rejections)","Ensure no auth middleware returns HTML/JSON that isn't a Plik file object"],"tags":["plik","http-response","missing-field","self-hosted"],"backgroundTag":"unexpected-response-shape","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}