{"record":{"id":"a714c00de3590b01","repo":"apereo/cas","slug":"does-not-match-the-recommended-pattern","errorCode":null,"errorMessage":"[{}] does not match the recommended pattern [{}]. While CAS tries to be forgiving as much as possible, it's recommended that you rename the file to match the requested pattern to avoid issues with duplicate service loading. Future CAS versions may try to strictly force the naming syntax, refusing to load the file.","messagePattern":"\\[(.+?)\\] does not match the recommended pattern \\[(.+?)\\]\\. While CAS tries to be forgiving as much as possible, it's recommended that you rename the file to match the requested pattern to avoid issues with duplicate service loading\\. Future CAS versions may try to strictly force the naming syntax, refusing to load the file\\.","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":288,"sourceCode":"        if (!file.exists()) {\n            LOGGER.warn(\"[{}] is not found at the path specified\", fileName);\n            return new ArrayList<>();\n        }\n        if (file.length() == 0) {\n            LOGGER.debug(\"[{}] appears to be empty so no service definition will be loaded\", fileName);\n            return new ArrayList<>();\n        }\n        if (!fileName.isEmpty() && fileName.charAt(0) == '.') {\n            LOGGER.debug(\"[{}] starts with ., ignoring\", fileName);\n            return new ArrayList<>();\n        }\n        if (Arrays.stream(getExtensions()).noneMatch(fileName::endsWith)) {\n            LOGGER.debug(\"[{}] doesn't end with valid extension, ignoring\", fileName);\n            return new ArrayList<>();\n        }\n\n        if (!RegexUtils.matches(this.serviceFileNamePattern, fileName)) {\n            LOGGER.warn(\"[{}] does not match the recommended pattern [{}]. \"\n                    + \"While CAS tries to be forgiving as much as possible, it's recommended \"\n                    + \"that you rename the file to match the requested pattern to avoid issues with duplicate service loading. \"\n                    + \"Future CAS versions may try to strictly force the naming syntax, refusing to load the file.\",\n                fileName, this.serviceFileNamePattern.pattern());\n        }\n\n        LOGGER.debug(\"Attempting to read and parse [{}]\", file.getAbsoluteFile());\n        try (val in = Files.newBufferedReader(file.toPath())) {\n            return registeredServiceSerializers\n                .stream()\n                .filter(serializer -> serializer.supports(file))\n                .map(serializer -> serializer.load(in))\n                .filter(Objects::nonNull)\n                .flatMap(Collection::stream)\n                .filter(service -> StringUtils.isNotBlank(service.getServiceId()) && StringUtils.isNotBlank(service.getName()))\n                .map(this::invokeServiceRegistryListenerPostLoad)\n                .filter(Objects::nonNull)\n                .collect(Collectors.toList());","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/core/cas-server-core-services-registry/src/main/java/org/apereo/cas/services/resource/AbstractResourceBasedServiceRegistry.java#L270-L306","documentation":"Service definition files must be named '<id>-<something>.<ext>' matching the registry's serviceFileNamePattern (id-based, e.g. 10000001-MyApp.json). If load(File) sees a file with a valid extension but a non-conforming name, CAS logs this warning and still loads it, but warns that duplicates and future strict enforcement may cause problems.","triggerScenarios":"Placing a file like 'myapp.json' or '10000001.json' (no dash-separated unique suffix) into the services directory, then having CAS scan/load it; RegexUtils.matches(serviceFileNamePattern, fileName) fails.","commonSituations":"Renaming files manually without following the CAS convention; migrating service definitions from another system; copy-paste of service files with arbitrary names.","solutions":["Rename the file to match the pattern '<numericId>-<serviceName>.json' (e.g. 10000001-MyApp.json).","Ensure the numeric id in the filename matches the id inside the JSON to avoid duplicate-loading issues.","Redeploy/mount the corrected files and reload the registry; confirm the warning disappears."],"exampleFix":"// before\nmv myapp.json /etc/cas/config/services/\n// after\nmv myapp.json /etc/cas/config/services/10000001-MyApp.json","handlingStrategy":"validation","validationCode":"// Validate filename before dropping into services dir\nString name = file.getName();\nif (!name.matches(\"\\\\d+-[\\\\w.-]+\\\\.(json|yaml|yml)\")) {\n    throw new IllegalArgumentException(\"Rename to <numericId>-<serviceName>.json: \" + name);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Follow the '<id>-<name>.json' naming convention for every service file.","Keep the filename id identical to the JSON 'id' field.","Add a lint step in your deployment pipeline that validates service file names."],"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"}