{"record":{"id":"fffb66f2a2098d72","repo":"nextcloud/server","slug":"the-http-nextcloud-com-ns-offset-has-illegal-va","errorCode":null,"errorMessage":"The {http://nextcloud.com/ns}offset has illegal value","messagePattern":"The (.+?)offset has illegal value","errorType":"http","errorClass":"Sabre\\DAV\\Exception\\BadRequest","httpStatus":400,"severity":"error","filePath":"apps/dav/lib/CalDAV/Search/Xml/Filter/OffsetFilter.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 OffsetFilter 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 . '}offset 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/OffsetFilter.php#L10-L34","documentation":"Same guard as the limit filter but for {http://nextcloud.com/ns}offset: OffsetFilter::xmlDeserialize() requires parseInnerTree() to return an int or string and otherwise throws Sabre\\DAV\\Exception\\BadRequest (HTTP 400). An empty <n:offset/> yields null and triggers it.","triggerScenarios":"Sending a search REPORT containing an empty <n:offset/> or an offset element wrapping child XML instead of a number.","commonSituations":"Pagination helper that renders offset unconditionally with a null value for page 0; clients upgraded from a format where offset defaulted to 0 when empty.","solutions":["Drop the <n:offset> element when the offset is 0 or unneeded","Otherwise send an explicit number: <n:offset>0</n:offset>","Unit-test the generated XML for empty pagination elements before shipping the client"],"exampleFix":"// before\n<n:offset/>\n\n// after\n<n:offset>0</n:offset>","handlingStrategy":"validation","validationCode":"$xml = '';\nif ($offset !== null && $offset > 0) {\n    $xml .= '<n:offset>' . (int) $offset . '</n:offset>'; // omit for page 0\n}","typeGuard":"function isValidOffset(mixed $offset): bool {\n    return $offset === null || (is_int($offset) && $offset >= 0);\n}","tryCatchPattern":"try {\n    $client->request('REPORT', $calendarUri, $xmlBody);\n} catch (\\Sabre\\Http\\ClientException $e) {\n    if ($e->getResponse()?->getStatus() === 400) { /* empty <n:offset/>: send integer or drop */ }\n}","preventionTips":["Treat offset 0 as 'omit the element', not 'send empty element'","Type pagination inputs as int in client models","Keep limit and offset handling symmetric in the payload builder"],"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"}