{"record":{"id":"6fbd892b0a07156b","repo":"apereo/cas","slug":"json-account-repository-file-is-not-found","errorCode":null,"errorMessage":"JSON account repository file [{}] is not found.","messagePattern":"JSON account repository file \\[(.+?)\\] is not found\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"support/cas-server-support-gauth-core/src/main/java/org/apereo/cas/gauth/credential/JsonGoogleAuthenticatorTokenCredentialRepository.java","lineNumber":71,"sourceCode":"        });\n    }\n\n    @Override\n    public OneTimeTokenAccount get(final String username, final long id) {\n        return lock.tryLock(() -> get(username)\n            .stream()\n            .filter(ac -> ac.getId() == id)\n            .findFirst()\n            .map(this::decode)\n            .orElse(null));\n    }\n\n    @Override\n    public Collection<? extends OneTimeTokenAccount> get(final String username) {\n        return lock.tryLock(() -> {\n            try {\n                if (!location.getFile().exists()) {\n                    LOGGER.warn(\"JSON account repository file [{}] is not found.\", location.getFile());\n                    return new ArrayList<>();\n                }\n\n                if (location.getFile().length() <= 0) {\n                    LOGGER.debug(\"JSON account repository file location [{}] is empty.\", location.getFile());\n                    return new ArrayList<>();\n                }\n                val map = serializer.from(location.getFile());\n                if (map == null) {\n                    LOGGER.debug(\"JSON account repository file [{}] is empty.\", location.getFile());\n                    return new ArrayList<>();\n                }\n\n                val account = map.get(username.trim().toLowerCase(Locale.ENGLISH));\n                if (account != null) {\n                    return decode(account);\n                }\n            } catch (final Exception e) {","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/support/cas-server-support-gauth-core/src/main/java/org/apereo/cas/gauth/credential/JsonGoogleAuthenticatorTokenCredentialRepository.java#L53-L89","documentation":"JsonGoogleAuthenticatorTokenCredentialRepository.get() reads accounts from a JSON file backed by a Spring Resource. If the file does not exist at the configured location it logs this warning and returns an empty list instead of failing, so lookups silently find no account.","triggerScenarios":"Calling get(username) when the configured ResourceLocation (e.g. cas.authn.mfa.gauth.core.json-file or a repository resource) points to a path that has not been created yet, typically on first startup before any account registration.","commonSituations":"Fresh deployment where the JSON store file was never initialized; wrong absolute path or missing mount in a container; file deleted by cleanup jobs; file expected on a classpath location that isn't packaged.","solutions":["Create the JSON account file at the configured location (can start as an empty JSON array) or ensure the path is writable so save() can create it","Verify the cas.authn.mfa.gauth.core.json-file/resource path is correct and reachable from the CAS process","If provisioning externally, mount or copy the pre-populated accounts file before startup","Confirm the resource is resolvable as a file (file: URLs must point to the actual filesystem, not inside an unreadable jar)"],"exampleFix":"// before\ncas.authn.mfa.gauth.core.json-file=/etc/cas/config/gauth-accnts.json\n// after (typo fixed and file pre-created with [])\ntouch /etc/cas/config/gauth-accounts.json && echo '[]' > /etc/cas/config/gauth-accounts.json\ncas.authn.mfa.gauth.core.json-file=file:/etc/cas/config/gauth-accounts.json","handlingStrategy":"fallback","validationCode":"// pre-check the configured store before login flows run\nResource loc = ...;\nboolean storeReady = loc != null && loc.getFile().exists() && loc.getFile().length() > 0;","typeGuard":null,"tryCatchPattern":"try {\n    accounts = repository.get(username);\n} catch (Exception e) {\n    accounts = List.of(); // empty fallback; treat as 'no devices registered'\n}","preventionTips":["Pre-create the JSON file (with []) before first startup","Verify file paths resolve on the real filesystem in containers/mounts","Use file: resource URLs and confirm CAS process read/write permissions","Add startup validation that the repository location exists and is writable"],"tags":["file","json","configuration","otp"],"backgroundTag":"file-not-found","analyzedSha":"e7288fc434b4f4505b8452e1a57e8fb3111bb863","analyzedAt":"2026-09-08T15:39:16.015Z","contentChangedAt":"2026-09-08T15:39:16.015Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}