{"record":{"id":"8a2ee4244e9b7710","repo":"passbolt/passbolt_api","slug":"the-file-0-could-not-be-read","errorCode":null,"errorMessage":"The file {0} could not be read.","messagePattern":"The file (.+?) could not be read\\.","errorType":"exception","errorClass":"SubscriptionException","httpStatus":500,"severity":"error","filePath":"plugins/PassboltEe/Subscription/src/Service/Subscriptions/SubscriptionKeyImportService.php","lineNumber":40,"sourceCode":"\n/**\n * Persists a subscription key supplied via file or text.\n */\nclass SubscriptionKeyImportService\n{\n    /**\n     * @param string $fileName Path to a file containing the subscription key.\n     * @param \\App\\Utility\\UserAccessControl $uac UAC object.\n     * @return \\Passbolt\\Subscription\\Model\\Dto\\SubscriptionKeyDto\n     * @throws \\Passbolt\\Subscription\\Error\\Exception\\Subscriptions\\SubscriptionException If the file or the contained subscription is not valid.\n     */\n    public function importFromFile(string $fileName, UserAccessControl $uac): SubscriptionKeyDto\n    {\n        if (!file_exists($fileName)) {\n            throw new SubscriptionException(__('The file {0} could not be found.', $fileName));\n        }\n        if (!is_readable($fileName)) {\n            throw new SubscriptionException(__('The file {0} could not be read.', $fileName));\n        }\n        $subscription = file_get_contents($fileName);\n        if (!$subscription) {\n            throw new SubscriptionException(__('The file {0} could not be read.', $fileName));\n        }\n\n        return $this->import($subscription, $uac);\n    }\n\n    /**\n     * @param string|null $subscription Raw subscription key payload (Base64).\n     * @param \\App\\Utility\\UserAccessControl $uac UAC object.\n     * @return \\Passbolt\\Subscription\\Model\\Dto\\SubscriptionKeyDto\n     * @throws \\Passbolt\\Subscription\\Error\\Exception\\Subscriptions\\SubscriptionException If the subscription is not valid.\n     */\n    public function import(?string $subscription, UserAccessControl $uac): SubscriptionKeyDto\n    {\n        return (new SubscriptionKeySaveService())->save($subscription, $uac);","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Subscription/src/Service/Subscriptions/SubscriptionKeyImportService.php#L22-L58","documentation":"SubscriptionKeyImportService::importFromFile() calls is_readable($fileName) after confirming the file exists; if the filesystem denies read access it throws SubscriptionException 'The file {0} could not be read.'","triggerScenarios":"Import invoked on an existing license file whose OS permissions, owner, or SELinux/AppArmor context prevent the PHP process user from reading it.","commonSituations":"License file uploaded by root or owned by another user (e.g. 0600 root:root) while PHP runs as www-data; restrictive umask after manual copy; Docker volume mounted with wrong ownership.","solutions":["Chown/chmod the file so the web/CLI PHP user can read it: chown www-data file && chmod 640 file","Check the directory's execute permission too (the PHP user must be able to traverse to the file)","Inspect SELinux/AppArmor denials in audit logs if permissions look correct"],"exampleFix":"// shell before\n-rw------- root root /etc/passbolt/subscription.txt\n// shell after\n-rw-r----- www-data www-data /etc/passbolt/subscription.txt","handlingStrategy":"validation","validationCode":"if (!is_readable($path)) { throw new RuntimeException(\"Cannot read $path as user \" . get_current_user()); }","typeGuard":"null","tryCatchPattern":"try { $svc->importFromFile($path, $uac); } catch (SubscriptionException $e) { // fix file ownership/permissions }","preventionTips":["Deploy license files owned by the PHP runtime user","Use chmod 640 and correct group ownership","Audit SELinux/AppArmor policies in hardened environments"],"tags":["passbolt","subscription","permissions","filesystem"],"backgroundTag":"file-read-failed","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}