can1357/oh-my-pi · error · Error

owncloud share response did not include a URL

Error message

owncloud share response did not include a URL

What it means

Thrown when the OCS 'data' section is absent, not an object, or lacks a 'url' key. The library requires data.url because the whole point of the share call is to obtain the public share URL it hands back to the user.

Source

Thrown at packages/coding-agent/src/blob-broker/uploaders-self-hosted.ts:63

function identifier(value: unknown): string | undefined {
	return typeof value === "string" || typeof value === "number" ? String(value) : undefined;
}

function ownCloudShare(value: unknown): OwnCloudShare {
	if (typeof value !== "object" || value === null || !("ocs" in value)) {
		throw new Error("owncloud share response did not include an OCS envelope");
	}
	const ocs = value.ocs;
	if (typeof ocs !== "object" || ocs === null || !("meta" in ocs) || !("data" in ocs)) {
		throw new Error("owncloud share response did not include OCS metadata and data");
	}
	const meta = ocs.meta;
	const data = ocs.data;
	if (typeof meta !== "object" || meta === null || !("statuscode" in meta)) {
		throw new Error("owncloud share response did not include an OCS status");
	}
	if (typeof data !== "object" || data === null || !("url" in data)) {
		throw new Error("owncloud share response did not include a URL");
	}
	const url = nonEmptyString(data.url);
	if (!url) throw new Error("owncloud share response did not include a URL");
	const id = "id" in data ? identifier(data.id) : undefined;
	return { statusCode: meta.statuscode, url, ...(id ? { id } : {}) };
}

function plikUpload(value: unknown): PlikUpload {
	if (typeof value !== "object" || value === null || !("id" in value) || !("uploadToken" in value)) {
		throw new Error("plik upload metadata did not include an id and upload token");
	}
	const id = identifier(value.id);
	const uploadToken = nonEmptyString(value.uploadToken);
	if (!id || !uploadToken) throw new Error("plik upload metadata did not include an id and upload token");
	let downloadBase: string | undefined;
	if ("downloadURL" in value) downloadBase = nonEmptyString(value.downloadURL);
	if (!downloadBase && "downloadDomain" in value) downloadBase = nonEmptyString(value.downloadDomain);
	return { id, uploadToken, ...(downloadBase ? { downloadBase } : {}) };

View on GitHub (pinned to 9690622007)

Solutions

  1. Check meta.statuscode in the same response: non-200 OCS status means the share was rejected — fix the underlying auth/permission problem first
  2. Verify the upload user has share-create permission and the files_sharing app is enabled on the server
  3. Ensure the target file/path exists (shares of nonexistent paths return no url)
  4. Test the same share call manually with curl against the OCS API to see the server's error message in data

Example fix

// before: data contains { message: "Could not create share" } on failure
// after: check OCS status before reading url, and fix server permissions
const parsed = ownCloudShare(body);
if (Number(parsed.statusCode) >= 400 || Number(parsed.statusCode) === 100) throw new Error(`share rejected: ${JSON.stringify(body)}`);
Defensive patterns

Strategy: validation

Validate before calling

// before trusting a share response, verify the OCS status code yourself
const res = await fetch(shareUrl, { headers: auth } );
const body = await res.json();
const status = Number(body?.ocs?.meta?.statuscode);
if (status !== 200 && status !== 100) throw new Error(`share rejected by server (OCS status ${status})`);
if (typeof body?.ocs?.data?.url !== "string" || !body.ocs.data.url) throw new Error("share response has no url — check share permissions");

Type guard

function hasShareUrl(value: unknown): value is { ocs: { meta: { statuscode: unknown }; data: { url: string } } } {
  const data = (value as any)?.ocs?.data;
  return typeof data === "object" && data !== null && typeof data.url === "string" && data.url.length > 0;
}

Try / catch

try {
  const share = await uploader.share();
} catch (err) {
  if ((err as Error).message.includes("did not include a URL")) {
    throw new Error("ownCloud did not return a share URL — verify the user can create share links and files_sharing is enabled");
  }
  throw err;
}

Prevention

When it happens

Trigger: The ownCloud share endpoint returned an OCS envelope whose data object has no 'url' field — e.g. the share failed server-side (statuscode 100/403/404) so data holds an error message instead of the created share, and the caller did not check statuscode first.

Common situations: Insufficient permissions for the upload user to create shares, share links disabled by admin policy, sharing the target folder blocked, or requesting shares on a server where the files_sharing app is disabled.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/8770d726f9a880b1. Report an issue: GitHub.