{"record":{"id":"85859927f62ecaac","repo":"passbolt/passbolt_api","slug":"the-file-0-could-not-be-found","errorCode":null,"errorMessage":"The file {0} could not be found.","messagePattern":"The file (.+?) could not be found\\.","errorType":"exception","errorClass":"SubscriptionException","httpStatus":500,"severity":"error","filePath":"plugins/PassboltEe/Subscription/src/Service/Subscriptions/SubscriptionKeyImportService.php","lineNumber":37,"sourceCode":"use App\\Utility\\UserAccessControl;\nuse Passbolt\\Subscription\\Error\\Exception\\Subscriptions\\SubscriptionException;\nuse Passbolt\\Subscription\\Model\\Dto\\SubscriptionKeyDto;\n\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     */","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Subscription/src/Service/Subscriptions/SubscriptionKeyImportService.php#L19-L55","documentation":"SubscriptionKeyImportService::importFromFile() first checks file_exists($fileName) and throws SubscriptionException if the license file cannot be found on disk. It fails before attempting any read or validation.","triggerScenarios":"Running the subscription import (command 'execute' -> importFromFile) with a file path that does not exist, e.g. a typo'd or relative path resolved against the wrong working directory.","commonSituations":"CLI import run from a different cwd than expected; license file uploaded to webroot but CLI references config path; container/volume not mounting the license file; filename with wrong extension or case (case-sensitive filesystems).","solutions":["Verify the absolute path exists: ls -l /path/to/subscription_key.txt","Pass an absolute path to the import command instead of a relative one","Check container/volume mounts so the license file is visible where the command runs"],"exampleFix":"// before\n$svc->importFromFile('subscription.txt', $uac);\n// after\n$path = CONFIG . 'subscription.txt';\nif (!file_exists($path)) { throw new Exception(\"License file missing: $path\"); }\n$svc->importFromFile($path, $uac);","handlingStrategy":"validation","validationCode":"if (!is_file($path)) { throw new InvalidArgumentException(\"License file not found: $path\"); }","typeGuard":"null","tryCatchPattern":"try { $svc->importFromFile($path, $uac); } catch (SubscriptionException $e) { // check file path in message }","preventionTips":["Always pass absolute paths to the import command","Ensure license files are baked into/mounted in containers","Verify path with ls/file_exists before importing"],"tags":["passbolt","subscription","filesystem"],"backgroundTag":"file-not-found","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"}