{"record":{"id":"8828b79df19fc867","repo":"can1357/oh-my-pi","slug":"owncloud-share-creation-returned-an-unsuccessful-o","errorCode":null,"errorMessage":"owncloud share creation returned an unsuccessful OCS status","messagePattern":"owncloud share creation returned an unsuccessful OCS status","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/blob-broker/uploaders-self-hosted.ts","lineNumber":335,"sourceCode":"\t\t\tconst shareForm = new FormData();\n\t\t\tshareForm.append(\"path\", `/${parts.join(\"/\")}`);\n\t\t\tshareForm.append(\"shareType\", \"3\");\n\t\t\tshareForm.append(\"permissions\", \"1\");\n\t\t\tif (expiryInfo.expireDate) shareForm.append(\"expireDate\", expiryInfo.expireDate);\n\t\t\tconst shareResponse = await expectOk(\n\t\t\t\tawait requestFetch(\n\t\t\t\t\t`${endpoint(host, \"ocs\", \"v1.php\", \"apps\", \"files_sharing\", \"api\", \"v1\", \"shares\")}?format=json`,\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\theaders: requestHeaders,\n\t\t\t\t\t\tbody: shareForm,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t\t\"owncloud\",\n\t\t\t);\n\t\t\tconst share = ownCloudShare(await shareResponse.json());\n\t\t\tif (share.statusCode !== 100 && share.statusCode !== \"100\") {\n\t\t\t\tthrow new Error(\"owncloud share creation returned an unsuccessful OCS status\");\n\t\t\t}\n\t\t\tconst url = preview\n\t\t\t\t? `${share.url.replace(/\\/$/, \"\")}/preview`\n\t\t\t\t: direct\n\t\t\t\t\t? `${share.url.replace(/\\/$/, \"\")}/download`\n\t\t\t\t\t: share.url;\n\t\t\tconst shareId = share.id;\n\t\t\tconst deleteAction: RemoteDeleteAction | undefined = shareId\n\t\t\t\t? {\n\t\t\t\t\t\tmethod: \"DELETE\",\n\t\t\t\t\t\turl: endpoint(host, \"ocs\", \"v1.php\", \"apps\", \"files_sharing\", \"api\", \"v1\", \"shares\", shareId),\n\t\t\t\t\t\theaders: requestHeaders,\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\t\t\treturn publication(\"owncloud\", request, url, {\n\t\t\t\t...(expiryInfo.expiresAt === undefined ? {} : { expiresAt: expiryInfo.expiresAt }),\n\t\t\t\t...(deleteAction ? { delete: deleteAction } : {}),\n\t\t\t\t...(shareId ? { remoteId: shareId } : {}),","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/blob-broker/uploaders-self-hosted.ts#L317-L353","documentation":"Thrown after a successful ownCloud share-creation API call when the OCS envelope's meta.statuscode is not 100 (the OCS \"ok\" code). The HTTP request may have succeeded, but the WebDAV PUT succeeded and the share request itself reports failure server-side (e.g. the file was not found or sharing is forbidden), so the upload cannot produce a public URL.","triggerScenarios":"POST to /ocs/v1.php/apps/files_sharing/api/v1/shares returning statuscode 403 (sharing disabled for user), 404 (path not found — e.g. the share path `/${parts.join('/')}` doesn't match the file just uploaded due to a path option mismatch), or 407/other OCS codes.","commonSituations":"options.path mismatch making the share path differ from the uploaded DAV path; sharing API disabled by the admin; public link sharing disallowed by share policy; ownCloud vs Next.js-style Nextcloud quirks in statuscode handling.","solutions":["Ensure options.path matches exactly where the file was PUT via WebDAV (share path is built as `/${pathParts}/${filename}` — case-sensitive).","Ask the ownCloud admin to enable the files_sharing app and allow public link shares for your user.","Check the server response body for the OCS message (e.g. 'Wrong path, file/folder does not exist') and correct directory/filename casing or accents.","Test the share manually: curl -u user:pass -H 'OCS-APIREQUEST: true' -F path=/file.txt -F shareType=3 .../ocs/v1.php/apps/files_sharing/api/v1/shares?format=json and inspect statuscode."],"exampleFix":"// before\noptions.path = \"Reports\";  // file uploaded to /remote.php/webdav/Reports/file.txt but share path built as /reports/file.txt elsewhere? ensure both identical\n// after\noptions.path = \"reports\";  // matches the directory actually used for the DAV PUT, so share path resolves","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await uploader.upload(request);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('unsuccessful OCS status')) {\n    // inspect the raw share response (path not found vs sharing disabled) before retrying\n    // 404 => fix options.path to match the uploaded WebDAV path; 403 => enable public sharing server-side\n  } else throw err;\n}","preventionTips":["Keep options.path byte-identical to the WebDAV PUT path (same casing, accents, leading segment).","Pre-flight the share API: POST a share for a known file and assert OCS statuscode 100 during setup.","Verify files_sharing is enabled and public links are allowed for the service account.","Avoid renaming/restructuring libraries between the upload and share steps."],"tags":["owncloud","ocs-api","sharing","http-api"],"backgroundTag":"ocs-share-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}