{"record":{"id":"3d2418e8c6adf8e5","repo":"nextcloud/server","slug":"the-http-nextcloud-com-ns-limit-has-illegal-val","errorCode":null,"errorMessage":"The {http://nextcloud.com/ns}limit has illegal value","messagePattern":"The (.+?)limit has illegal value","errorType":"http","errorClass":"Sabre\\DAV\\Exception\\BadRequest","httpStatus":400,"severity":"error","filePath":"apps/dav/lib/CalDAV/Search/Xml/Filter/LimitFilter.php","lineNumber":28,"sourceCode":"namespace OCA\\DAV\\CalDAV\\Search\\Xml\\Filter;\n\nuse OCA\\DAV\\CalDAV\\Search\\SearchPlugin;\nuse Sabre\\DAV\\Exception\\BadRequest;\nuse Sabre\\Xml\\Reader;\nuse Sabre\\Xml\\XmlDeserializable;\n\nclass LimitFilter implements XmlDeserializable {\n\n\t/**\n\t * @param Reader $reader\n\t * @throws BadRequest\n\t * @return int\n\t */\n\t#[\\Override]\n\tpublic static function xmlDeserialize(Reader $reader) {\n\t\t$value = $reader->parseInnerTree();\n\t\tif (!is_int($value) && !is_string($value)) {\n\t\t\tthrow new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}limit has illegal value');\n\t\t}\n\n\t\treturn (int)$value;\n\t}\n}\n","sourceCodeStart":10,"sourceCodeEnd":34,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/dav/lib/CalDAV/Search/Xml/Filter/LimitFilter.php#L10-L34","documentation":"Thrown when deserializing the {http://nextcloud.com/ns}limit element of a Nextcloud CalDAV search REPORT: parseInnerTree() returned something that is neither int nor string (typically null for an empty element), so LimitFilter::xmlDeserialize() raises Sabre\\DAV\\Exception\\BadRequest (HTTP 400). The element must contain a numeric text value.","triggerScenarios":"Sending <n:limit/> (self-closing, empty) or one whose content deserializes to a non-scalar, e.g. nested child elements instead of text.","commonSituations":"Client code that always emits limit/offset tags but leaves them empty when no pagination is set; templates copied from another namespace where the element is a no-op.","solutions":["Omit the <n:limit> element entirely when you do not want pagination","Otherwise give it text content: <n:limit>50</n:limit>","Check your serializer is not dropping scalar text content of empty-valued fields"],"exampleFix":"// before\n<n:limit/>\n\n// after\n<n:limit>50</n:limit>","handlingStrategy":"validation","validationCode":"$xml = '';\nif ($limit !== null) {\n    $xml .= '<n:limit>' . (int) $limit . '</n:limit>'; // omit entirely when unset\n}","typeGuard":"function isValidLimit(mixed $limit): bool {\n    return $limit === null || (is_int($limit) && $limit > 0);\n}","tryCatchPattern":"try {\n    $client->request('REPORT', $calendarUri, $xmlBody);\n} catch (\\Sabre\\Http\\ClientException $e) {\n    if ($e->getResponse()?->getStatus() === 400) { /* empty <n:limit/>: send text or drop element */ }\n}","preventionTips":["Render pagination elements only with concrete integer values","Never emit self-closing limit/offset tags","Schema-check outgoing XML in dev builds (assert no empty n: elements)"],"tags":["caldav","xml","search","pagination","nextcloud","bad-request"],"backgroundTag":"webdav-400-bad-request","analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}