{"record":{"id":"8a93bfb0c5213366","repo":"nextcloud/server","slug":"expiration-time-should-be-greater-than-0-and-less","errorCode":null,"errorMessage":"Expiration time should be greater than 0 and less than or equal to 86400","messagePattern":"Expiration time should be greater than 0 and less than or equal to 86400","errorType":"exception","errorClass":"OCP\\AppFramework\\OCS\\OCSBadRequestException","httpStatus":400,"severity":"error","filePath":"apps/dav/lib/Controller/DirectController.php","lineNumber":75,"sourceCode":"\t *\n\t * 200: Direct link returned\n\t */\n\t#[NoAdminRequired]\n\tpublic function getUrl(int $fileId, int $expirationTime = 60 * 60 * 8): DataResponse {\n\t\tif (!$this->shareManager->shareApiAllowLinks()) {\n\t\t\tthrow new OCSForbiddenException('Creating direct links is disabled');\n\t\t}\n\n\t\t$userFolder = $this->rootFolder->getUserFolder($this->userId);\n\n\t\t$file = $userFolder->getFirstNodeById($fileId);\n\n\t\tif (!$file) {\n\t\t\tthrow new OCSNotFoundException();\n\t\t}\n\n\t\tif ($expirationTime <= 0 || $expirationTime > (60 * 60 * 24)) {\n\t\t\tthrow new OCSBadRequestException('Expiration time should be greater than 0 and less than or equal to ' . (60 * 60 * 24));\n\t\t}\n\n\t\tif (!($file instanceof File)) {\n\t\t\tthrow new OCSBadRequestException('Direct download only works for files');\n\t\t}\n\n\t\t$event = new BeforeDirectFileDownloadEvent($userFolder->getRelativePath($file->getPath()));\n\t\t$this->eventDispatcher->dispatchTyped($event);\n\n\t\tif ($event->isSuccessful() === false) {\n\t\t\tthrow new OCSForbiddenException('Permission denied to download file');\n\t\t}\n\n\t\t//TODO: at some point we should use the directdownlaod function of storages\n\t\t$direct = new Direct();\n\t\t$direct->setUserId($this->userId);\n\t\t$direct->setFileId($fileId);\n","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/dav/lib/Controller/DirectController.php#L57-L93","documentation":"Error \"Expiration time should be greater than 0 and less than or equal to 86400\" thrown in nextcloud/server.","triggerScenarios":"Thrown at apps/dav/lib/Controller/DirectController.php:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}