can1357/oh-my-pi · error · Error

owncloud share response did not include an OCS status

Error message

owncloud share response did not include an OCS status

What it means

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.

Source

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

	return typeof value === "string" && value.length > 0 ? value : undefined;
}

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;

View on GitHub (pinned to 9690622007)

Solutions

  1. Confirm the correct OCS endpoint/API version is configured so the server returns standard { ocs: { meta: { statuscode }, data } } JSON
  2. Ensure the request asks for JSON (the uploader expects JSON, not the default OCS XML)
  3. Inspect the raw response with curl -u user:pass to see the actual meta payload
  4. Check for proxies/security middleware altering response bodies

Example fix

// before: server returns OCS XML because Accept header not honored
// after: force JSON responses from the OCS endpoint
fetch(url, { headers: { "OCS-APIRequest": "true", Accept: "application/json", ...auth } })
Defensive patterns

Strategy: type-guard

Validate before calling

function ocsMetaHasStatus(body: unknown): boolean {
  const ocs = (body as any)?.ocs;
  return typeof ocs?.meta === "object" && ocs?.meta !== null && "statuscode" in ocs.meta;
}

Type guard

function hasOcsStatus(value: unknown): value is { ocs: { meta: { statuscode: unknown }; data: unknown } } {
  const ocs = (value as any)?.ocs;
  return typeof ocs === "object" && ocs !== null && typeof ocs.meta === "object" && ocs.meta !== null && "statuscode" in ocs.meta;
}

Try / catch

try {
  const share = await uploader.share();
} catch (err) {
  if ((err as Error).message.includes("OCS status")) {
    logger.error("ownCloud response meta missing statuscode — likely XML response or wrong API version", { err });
  }
  throw err;
}

Prevention

When it happens

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

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

Related errors


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