{"record":{"id":"19e2046a102be42f","repo":"nextcloud/server","slug":"http-nextcloud-com-ns-search-term-is-required-f","errorCode":null,"errorMessage":"{http://nextcloud.com/ns}search-term is required for this request","messagePattern":"(.+?)search-term is required for this request","errorType":"http","errorClass":"Sabre\\DAV\\Exception\\BadRequest","httpStatus":400,"severity":"error","filePath":"apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php","lineNumber":141,"sourceCode":"\t\t\t\tcase '{' . SearchPlugin::NS_Nextcloud . '}offset':\n\t\t\t\t\t$newProps['offset'] = $elem['value'];\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\t\t}\n\n\t\tif (empty($newProps['filters'])) {\n\t\t\tthrow new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');\n\t\t}\n\n\t\t$propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));\n\t\t$noCompsDefined = empty($newProps['filters']['comps']);\n\t\tif ($propsOrParamsDefined && $noCompsDefined) {\n\t\t\tthrow new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');\n\t\t}\n\n\t\tif (!isset($newProps['filters']['search-term'])) {\n\t\t\tthrow new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');\n\t\t}\n\n\t\tif (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) {\n\t\t\tthrow new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request');\n\t\t}\n\n\t\t$obj = new self();\n\t\tforeach ($newProps as $key => $value) {\n\t\t\t$obj->$key = $value;\n\t\t}\n\t\treturn $obj;\n\t}\n}\n","sourceCodeStart":123,"sourceCodeEnd":155,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php#L123-L155","documentation":"CalendarSearchReport::xmlDeserialize() requires a {http://nextcloud.com/ns}search-term inside the filter; when filters were given but isset($newProps['filters']['search-term']) is false it throws Sabre\\DAV\\Exception\\BadRequest (HTTP 400). The Nextcloud search REPORT always performs substring matching, so the term is not optional.","triggerScenarios":"Sending a filter block with comp-filter and prop-filter elements but no <n:search-term>text</n:search-term> child.","commonSituations":"Attempting a 'list all events' style query by omitting the term; client versions that modeled search-term as optional; empty term serialized as a missing element.","solutions":["Add <n:search-term>...</n:search-term> inside <n:filter>","For listing without a term, use a plain calender-query REPORT (time-range filter) or PROPFIND instead of the Nextcloud search report","Guard client-side: if the term is empty, either block the request or switch to the listing query"],"exampleFix":"// before\n<n:filter><n:comp-filter name=\"VEVENT\"/><n:prop-filter name=\"SUMMARY\"/></n:filter>\n\n// after\n<n:filter>\n  <n:comp-filter name=\"VEVENT\"/>\n  <n:prop-filter name=\"SUMMARY\"/>\n  <n:search-term>meeting</n:search-term>\n</n:filter>","handlingStrategy":"validation","validationCode":"if (!isValidSearchTerm($term)) {\n    // switch to a plain calendar-query REPORT / PROPFIND for listing, or require a term\n    throw new InvalidArgumentException('search-term is required');\n}","typeGuard":"function reportHasSearchTerm(array $newProps): bool {\n    return isset($newProps['filters']['search-term'])\n        && is_string($newProps['filters']['search-term']);\n}","tryCatchPattern":"try {\n    $client->request('REPORT', $calendarUri, $xmlBody);\n} catch (\\Sabre\\Http\\ClientException $e) {\n    if ($e->getResponse()?->getStatus() === 400) { /* add <n:search-term> inside n:filter */ }\n}","preventionTips":["Reserve the Nextcloud search report for substring searches; use caldav calendar-query for listing","Make search-term a required parameter of your search API wrapper","Escape the term text as XML"],"tags":["caldav","xml","search","nextcloud","bad-request","search-term"],"backgroundTag":"webdav-400-bad-request","analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}