{"record":{"id":"7ecef01f5c51cb56","repo":"nextcloud/server","slug":"location-location-is-not-valid-cannot-open-loc-7ecef0","errorCode":null,"errorMessage":"Location <$location> is not valid. Cannot open location for read operation.","messagePattern":"Location <\\$location> is not valid\\. Cannot open location for read operation\\.","errorType":"console","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"apps/dav/lib/Command/ImportCalendar.php","lineNumber":112,"sourceCode":"\t\tif ($calendar->isDeleted()) {\n\t\t\tthrow new InvalidArgumentException(\"Calendar <$calendarId> is deleted\");\n\t\t}\n\t\t// construct options object\n\t\t$options = new CalendarImportOptions();\n\t\t$options->setSupersede($supersede);\n\t\tif ($errors !== null) {\n\t\t\t$options->setErrors($errors);\n\t\t}\n\t\tif ($validation !== null) {\n\t\t\t$options->setValidate($validation);\n\t\t}\n\t\t$options->setFormat($format);\n\t\t$options->setCounts(true);\n\t\t// evaluate if a valid location was given and is usable otherwise default to stdin\n\t\tif ($location !== null) {\n\t\t\t$stream = fopen($location, 'r');\n\t\t\tif ($stream === false) {\n\t\t\t\tthrow new InvalidArgumentException(\"Location <$location> is not valid. Cannot open location for read operation.\");\n\t\t\t}\n\t\t} else {\n\t\t\t$stdin = fopen('php://stdin', 'r');\n\t\t\tif ($stdin === false) {\n\t\t\t\tthrow new InvalidArgumentException('Cannot open stdin for read operation.');\n\t\t\t}\n\t\t\t$tempPath = $this->tempManager->getTemporaryFile();\n\t\t\t$stream = fopen($tempPath, 'w+');\n\t\t\twhile (!feof($stdin)) {\n\t\t\t\tfwrite($stream, fread($stdin, 8192));\n\t\t\t}\n\t\t\tfclose($stdin);\n\t\t\tfseek($stream, 0);\n\t\t}\n\t\t$timeStarted = microtime(true);\n\t\t$totalCreated = 0;\n\t\t$totalUpdated = 0;\n\t\t$totalSkipped = 0;","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/dav/lib/Command/ImportCalendar.php#L94-L130","documentation":"InvalidArgumentException thrown by occ dav:import-calendar (apps/dav/lib/Command/ImportCalendar.php:112) when fopen($location, 'r') fails - the input file argument cannot be opened for reading. Happens for missing files, unreadable permissions, wrong path, or open_basedir restrictions.","triggerScenarios":"occ dav:import-calendar alice personal /path/to/calendar.ics where the file does not exist relative to the occ process cwd, is not readable by the occ user (www-data), or lies outside open_basedir.","commonSituations":"Relative paths resolved from the web root instead of the shell cwd; file uploaded as root and not readable by www-data; typos; running occ in a container without the mounted file.","solutions":["Use an absolute path and verify it exists: ls -l /abs/path/calendar.ics","chmod a+r (or chown www-data) so the occ user can read it","Omit the location argument and pipe stdin instead: cat calendar.ics | occ dav:import-calendar alice personal"],"exampleFix":"# before\nocc dav:import-calendar alice personal cal.ics        # run from wrong cwd\n# after\nocc dav:import-calendar alice personal /home/alice/cal.ics\n# or stream via stdin\ncat /home/alice/cal.ics | occ dav:import-calendar alice personal","handlingStrategy":"validation","validationCode":"// shell: verify the input file before occ\nif (!is_file($path) || !is_readable($path)) {\n    throw new RuntimeException(\"Cannot read $path\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute paths for the import file","chmod a+r files created by other users","Fall back to stdin piping: cat file.ics | occ dav:import-calendar uid uri"],"tags":["occ","cli","import","calendar","fopen","file-permissions","invalid-path"],"backgroundTag":"file-open-failed","analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}