nextcloud/server · error · InvalidArgumentException

Specify the URI of the calendar to be deleted

Error message

Specify the URI of the calendar to be deleted

What it means

InvalidArgumentException from occ dav:delete-subscription when the uri argument is present but empty after casting to string. Although declared REQUIRED, Symfony console accepts an empty string for required arguments in some invocation styles, so the command guards explicitly and refuses to query with an empty URI.

Source

Thrown at apps/dav/lib/Command/DeleteSubscription.php:58

				'User who owns the calendar subscription'
			)
			->addArgument(
				'uri',
				InputArgument::REQUIRED,
				'URI of the calendar to be deleted'
			);
	}

	#[\Override]
	protected function execute(InputInterface $input, OutputInterface $output): int {
		$user = (string)$input->getArgument('uid');
		if (!$this->userManager->userExists($user)) {
			throw new \InvalidArgumentException("User $user is unknown");
		}

		$uri = (string)$input->getArgument('uri');
		if ($uri === '') {
			throw new \InvalidArgumentException('Specify the URI of the calendar to be deleted');
		}

		$subscriptionInfo = $this->calDavBackend->getSubscriptionByUri(
			'principals/users/' . $user,
			$uri
		);

		if ($subscriptionInfo === null) {
			throw new \InvalidArgumentException("User $user has no calendar subscription with the URI $uri");
		}

		$subscription = new CachedSubscription(
			$this->calDavBackend,
			$subscriptionInfo,
		);

		$subscription->delete();

View on GitHub (pinned to ecdeb153ff)

Solutions

  1. Pass the exact subscription URI: list them first with occ dav:list-subscriptions <uid>
  2. Validate that the uri variable is non-empty before invoking the command in scripts
  3. Skip rows with blank URIs in batch imports and report them separately

Example fix

# before: empty uri argument
occ dav:delete-subscription jdoe ''
# after: list subscriptions, then pass the exact URI
occ dav:list-subscriptions jdoe
occ dav:delete-subscription jdoe company-holidays
Defensive patterns

Strategy: validation

Validate before calling

#!/bin/bash
uid="$1"; uri="$2"
if [ -z "$uri" ]; then
  occ dav:list-subscriptions "$uid"  # show valid URIs
  echo 'pass a subscription URI' >&2; exit 1
fi
occ dav:delete-subscription "$uid" "$uri"

Prevention

When it happens

Trigger: occ dav:delete-subscription <uid> '' or a wrapper forwarding an unset/empty URI variable; JSON/CSV-driven scripts where the uri column is blank for a row.

Common situations: Shell wrappers passing "$uri" when uri is unset; CSV rows with missing values; nested quoting that collapses the argument to an empty string.

Related errors


AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17). Data as JSON: /api/errors/e129df470c160018. Report an issue: GitHub.