{"record":{"id":"b5df074bc1b4e9f6","repo":"can1357/oh-my-pi","slug":"owncloud-share-response-did-not-include-an-ocs-sta","errorCode":null,"errorMessage":"owncloud share response did not include an OCS status","messagePattern":"owncloud share response did not include an OCS status","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/blob-broker/uploaders-self-hosted.ts","lineNumber":60,"sourceCode":"\treturn typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\nfunction identifier(value: unknown): string | undefined {\n\treturn typeof value === \"string\" || typeof value === \"number\" ? String(value) : undefined;\n}\n\nfunction ownCloudShare(value: unknown): OwnCloudShare {\n\tif (typeof value !== \"object\" || value === null || !(\"ocs\" in value)) {\n\t\tthrow new Error(\"owncloud share response did not include an OCS envelope\");\n\t}\n\tconst ocs = value.ocs;\n\tif (typeof ocs !== \"object\" || ocs === null || !(\"meta\" in ocs) || !(\"data\" in ocs)) {\n\t\tthrow new Error(\"owncloud share response did not include OCS metadata and data\");\n\t}\n\tconst meta = ocs.meta;\n\tconst data = ocs.data;\n\tif (typeof meta !== \"object\" || meta === null || !(\"statuscode\" in meta)) {\n\t\tthrow new Error(\"owncloud share response did not include an OCS status\");\n\t}\n\tif (typeof data !== \"object\" || data === null || !(\"url\" in data)) {\n\t\tthrow new Error(\"owncloud share response did not include a URL\");\n\t}\n\tconst url = nonEmptyString(data.url);\n\tif (!url) throw new Error(\"owncloud share response did not include a URL\");\n\tconst id = \"id\" in data ? identifier(data.id) : undefined;\n\treturn { statusCode: meta.statuscode, url, ...(id ? { id } : {}) };\n}\n\nfunction plikUpload(value: unknown): PlikUpload {\n\tif (typeof value !== \"object\" || value === null || !(\"id\" in value) || !(\"uploadToken\" in value)) {\n\t\tthrow new Error(\"plik upload metadata did not include an id and upload token\");\n\t}\n\tconst id = identifier(value.id);\n\tconst uploadToken = nonEmptyString(value.uploadToken);\n\tif (!id || !uploadToken) throw new Error(\"plik upload metadata did not include an id and upload token\");\n\tlet downloadBase: string | undefined;","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/blob-broker/uploaders-self-hosted.ts#L42-L78","documentation":"Thrown by the ownCloudShare validator when the OCS envelope has 'meta' and 'data' keys, but 'meta' is not an object or does not contain a 'statuscode' field. The library reads meta.statuscode to check share success, so a response whose meta section is missing or malformed cannot be validated.","triggerScenarios":"The ownCloud/Nextcloud share response contains an ocs object whose 'meta' is null, a string/array, or an object without 'statuscode' — typically when a non-OCS JSON body coincidentally has an 'ocs' key, or the server returns a truncated/error payload.","commonSituations":"Server-side plugin or app returning custom JSON, an API version whose meta uses a different field name, or a middleware stripping/renaming fields; also hit when the response was actually an XML OCS payload parsed incorrectly.","solutions":["Confirm the correct OCS endpoint/API version is configured so the server returns standard { ocs: { meta: { statuscode }, data } } JSON","Ensure the request asks for JSON (the uploader expects JSON, not the default OCS XML)","Inspect the raw response with curl -u user:pass to see the actual meta payload","Check for proxies/security middleware altering response bodies"],"exampleFix":"// before: server returns OCS XML because Accept header not honored\n// after: force JSON responses from the OCS endpoint\nfetch(url, { headers: { \"OCS-APIRequest\": \"true\", Accept: \"application/json\", ...auth } })","handlingStrategy":"type-guard","validationCode":"function ocsMetaHasStatus(body: unknown): boolean {\n  const ocs = (body as any)?.ocs;\n  return typeof ocs?.meta === \"object\" && ocs?.meta !== null && \"statuscode\" in ocs.meta;\n}","typeGuard":"function hasOcsStatus(value: unknown): value is { ocs: { meta: { statuscode: unknown }; data: unknown } } {\n  const ocs = (value as any)?.ocs;\n  return typeof ocs === \"object\" && ocs !== null && typeof ocs.meta === \"object\" && ocs.meta !== null && \"statuscode\" in ocs.meta;\n}","tryCatchPattern":"try {\n  const share = await uploader.share();\n} catch (err) {\n  if ((err as Error).message.includes(\"OCS status\")) {\n    logger.error(\"ownCloud response meta missing statuscode — likely XML response or wrong API version\", { err });\n  }\n  throw err;\n}","preventionTips":["Request JSON from the OCS API (Accept: application/json, OCS-APIRequest: true) so meta parses as expected","Verify the server returns standard OCS meta with statuscode via a manual curl call","Check for middleware/security plugins that rewrite or strip response fields"],"tags":["owncloud","nextcloud","ocs","response-parsing"],"backgroundTag":"api-response-schema-mismatch","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}