{"record":{"id":"bf3873c4e355d43f","repo":"apereo/cas","slug":"provided-file-does-not-match-the-recommended","errorCode":null,"errorMessage":"Provided file [{}] does not match the recommended service definition file pattern [{}]","messagePattern":"Provided file \\[(.+?)\\] does not match the recommended service definition file pattern \\[(.+?)\\]","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/cas-server-core-services-registry/src/main/java/org/apereo/cas/services/resource/AbstractResourceBasedServiceRegistry.java","lineNumber":366,"sourceCode":"        if (!fileName.isEmpty() && fileName.charAt(0) == '.') {\n            LOGGER.trace(\"[{}] starts with ., ignoring...\", fileName);\n            return null;\n        }\n        if (Arrays.stream(getExtensions()).noneMatch(fileName::endsWith)) {\n            LOGGER.trace(\"[{}] doesn't end with valid extension, ignoring\", fileName);\n            return null;\n        }\n        val matcher = this.serviceFileNamePattern.matcher(fileName);\n        if (matcher.find()) {\n            val serviceId = matcher.group(2);\n            if (NumberUtils.isCreatable(serviceId)) {\n                val id = Long.parseLong(serviceId);\n                return findServiceById(id);\n            }\n            val serviceName = matcher.group(1);\n            return findServiceByExactServiceName(serviceName);\n        }\n        LOGGER.warn(\"Provided file [{}] does not match the recommended service definition file pattern [{}]\",\n            file.getName(),\n            this.serviceFileNamePattern.pattern());\n        return null;\n    }\n\n    protected File getRegisteredServiceFileName(final RegisteredService service) {\n        val fileName = resourceNamingStrategy.build(service, getExtensions()[0]);\n\n        val parentDirectory = determineParentDirectoryFor(service);\n        val svcFile = new File(parentDirectory, fileName);\n        LOGGER.debug(\"Using [{}] as the service definition file\", svcFile.getAbsolutePath());\n        return svcFile;\n    }\n\n    private File determineParentDirectoryFor(final RegisteredService service) {\n        val defaultServicesDirectory = serviceRegistryDirectory.toFile();\n\n        val friendlyName = service.getFriendlyName();","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/core/cas-server-core-services-registry/src/main/java/org/apereo/cas/services/resource/AbstractResourceBasedServiceRegistry.java#L348-L384","documentation":"getRegisteredServiceFromFile parses a filename to find the service it contains (extracting id or name via the serviceFileNamePattern). When the filename does not match the pattern, no matcher groups exist, CAS logs this warning and returns null — the service cannot be resolved from that file.","triggerScenarios":"Watcher/reload paths calling getRegisteredServiceFromFile(file) on a file whose name (e.g. 'service-backup.json') doesn't match '<id>-<name>.<ext>'; pattern match produced no groups.","commonSituations":"Backup or temp files (e.g. '1001-app.json.bak~', editor swap files) in the services directory; files renamed while CAS watches the directory.","solutions":["Rename the file to the required '<numericId>-<serviceName>.json' format.","Remove backup/editor/temp files from the services directory so they are never parsed.","If the file is intentionally non-standard, move it outside the watched services directory."],"exampleFix":"// before\n/etc/cas/config/services/1001-app.json.bak   // triggers warning\n// after\nmv /etc/cas/config/services/1001-app.json.bak ~/backups/","handlingStrategy":"validation","validationCode":"// Same guard as 395, applied before files reach the watched directory\nif (!fileName.matches(\"\\\\d+-[^.]+\\\\.json\")) {\n    throw new IllegalArgumentException(\"Service file must be <id>-<name>.json\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep backups, editor swap files, and temp files out of the services directory.","Only deploy conformingly named files into the watched directory.","Sync tools (git, rsync) should exclude non-service files from the directory."],"tags":["naming","service-registry","files"],"backgroundTag":"invalid-identifier-format","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"}