{"record":{"id":"8be6293a3b766c3b","repo":"phalcon/cphalcon","slug":"stream-adapter-file-does-not-exist-path","errorCode":null,"errorMessage":"Stream adapter file does not exist: {path}","messagePattern":"Stream adapter file does not exist: (.+?)","errorType":"exception","errorClass":"Phalcon\\Auth\\Exceptions\\FileDoesNotExist","httpStatus":null,"severity":"error","filePath":"phalcon/Auth/Adapter/Stream.zep","lineNumber":73,"sourceCode":"        );\n    }\n\n    /**\n     * Loads and decodes the JSON users file. Re-read on every call - if you\n     * need caching, wrap it.\n     *\n     * @phpstan-return list<AuthUserRow>\n     *\n     * @throws Exception\n     */\n    protected function loadUsers() -> array\n    {\n        var contents, data, ex, path, rows;\n\n        let path = this->config->getFile();\n\n        if (!this->phpFileExists(path)) {\n            throw new FileDoesNotExist(path);\n        }\n\n        let contents = this->phpFileGetContents(path);\n\n        if (contents === false) {\n            throw new FileCannotRead(path);\n        }\n\n        try {\n            let data = (new Decode())->__invoke(contents, true);\n        } catch InvalidArgumentException, ex {\n            throw new FileNotValidJson(path, ex);\n        }\n\n        if (typeof data !== \"array\") {\n            throw new FileDoesNotContainJson(path);\n        }\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Auth/Adapter/Stream.zep#L55-L91","documentation":"The Auth Stream adapter keeps its user store in a JSON file whose path comes from StreamAdapterConfig. On the first authentication attempt it lazily loads users and starts by checking file existence; a missing file yields FileDoesNotExist with the configured path, before any read or JSON parsing happens.","triggerScenarios":"Authenticating via the Stream adapter when config->getFile() points to a path that does not exist: wrong filename, relative path resolved against a different working directory, or the file simply never deployed.","commonSituations":"Relative paths breaking between web and CLI entry points; environment-specific users file omitted from deployment; typo in the config key; fresh clone without the seed file.","solutions":["Create the users file at the exact path shown in the message and seed it with a JSON array","Use an absolute path (or one built from a known base constant) so resolution does not depend on CWD","Add the file to your deployment/seed scripts and .gitignore policy as appropriate"],"exampleFix":"// before\n$adapter = new \\Phalcon\\Auth\\Adapter\\Stream($hasher, new StreamAdapterConfig(['file' => 'storage/users.json']));\n// after\n$file = dirname(__DIR__) . '/storage/users.json';\nif (!is_file($file)) {\n    file_put_contents($file, \"[]\"); // or ship a seeded users file\n}\n$adapter = new \\Phalcon\\Auth\\Adapter\\Stream($hasher, new StreamAdapterConfig(['file' => $file]));","handlingStrategy":"validation","validationCode":"$file = $config->getFile();\nif (!is_file($file)) {\n    throw new RuntimeException('Auth users file missing: ' . $file);\n}\n$adapter = new \\Phalcon\\Auth\\Adapter\\Stream($hasher, $config);","typeGuard":null,"tryCatchPattern":"try {\n    $guard->attempt($credentials);\n} catch (\\Phalcon\\Auth\\Exceptions\\FileDoesNotExist $e) {\n    $logger->critical('Auth users file missing: ' . $e->getMessage());\n    throw new RuntimeException('Authentication store unavailable', 0, $e);\n}","preventionTips":["Use absolute paths for the users file built from a known base constant","Include/seed the users file in deployment scripts and verify presence in a health check","Fail a startup probe if the configured auth file is absent"],"tags":["auth","stream-adapter","file-not-found","configuration"],"backgroundTag":"file-not-found","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}