{"record":{"id":"e7eb976260cd3926","repo":"apereo/cas","slug":"found-a-service-definition-with-a-duplicate-i","errorCode":null,"errorMessage":"Found a service definition [{}] with a duplicate id [{}]. This will overwrite previous service definitions and is likely a configuration problem. Make sure all services have a unique id and try again.","messagePattern":"Found a service definition \\[(.+?)\\] with a duplicate id \\[(.+?)\\]\\. This will overwrite previous service definitions and is likely a configuration problem\\. Make sure all services have a unique id and try again\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/cas-server-core-services-registry/src/main/java/org/apereo/cas/services/resource/BaseResourceBasedRegisteredServiceWatcher.java","lineNumber":23,"sourceCode":"import lombok.AccessLevel;\nimport lombok.RequiredArgsConstructor;\nimport lombok.extern.slf4j.Slf4j;\nimport org.jooq.lambda.fi.util.function.CheckedConsumer;\n\n/**\n * This is {@link BaseResourceBasedRegisteredServiceWatcher}.\n *\n * @author Misagh Moayyed\n * @since 5.2.0\n */\n@Slf4j\n@RequiredArgsConstructor(access = AccessLevel.PROTECTED)\npublic abstract class BaseResourceBasedRegisteredServiceWatcher implements CheckedConsumer<File> {\n    /**\n     * Consumer to log warnings for duplicate service defns.\n     */\n    static final Consumer<RegisteredService> LOG_SERVICE_DUPLICATE =\n        service -> LOGGER.warn(\"Found a service definition [{}] with a duplicate id [{}]. \"\n                               + \"This will overwrite previous service definitions and is likely a configuration problem. \"\n                               + \"Make sure all services have a unique id and try again.\", service.getServiceId(), service.getId());\n\n    /**\n     * Service registry instance.\n     */\n    protected final AbstractResourceBasedServiceRegistry serviceRegistryDao;\n\n    @Override\n    public void accept(final File file) {\n    }\n}\n","sourceCodeStart":5,"sourceCodeEnd":36,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/core/cas-server-core-services-registry/src/main/java/org/apereo/cas/services/resource/BaseResourceBasedRegisteredServiceWatcher.java#L5-L36","documentation":"BaseResourceBasedRegisteredServiceWatcher.LOG_SERVICE_DUPLICATE warns when two service definition files in the registry directory resolve to the same service id. The later-loaded definition overwrites the earlier one, which is almost always a misconfiguration; the consumer is used during load to flag duplicates.","triggerScenarios":"Two JSON files in the services directory both containing \"id\": 1001 (e.g. an old file plus a renamed copy) while the registry loads and deduplicates; load() detects the same id twice and applies LOG_SERVICE_DUPLICATE.","commonSituations":"Copying a service file to make a variant but forgetting to change its internal id; leftover files from upgrades/migrations; filename id and internal JSON id disagreeing.","solutions":["List all service files and grep their ids; delete or correct the file containing the duplicate id.","Give each service definition a unique numeric id (both in the filename and the JSON 'id' field).","Reload the registry and confirm each service loads exactly once."],"exampleFix":"// before: two files both with id 1001\n1001-App.json {\"id\": 1001, ...}\n1001-AppCopy.json {\"id\": 1001, ...}\n// after\n1001-App.json {\"id\": 1001, ...}\n1002-AppCopy.json {\"id\": 1002, ...}","handlingStrategy":"validation","validationCode":"# Shell: detect duplicate ids across service files before startup\ngrep -h '\"id\"' /etc/cas/config/services/*.json \\\n  | sort | uniq -d && echo 'DUPLICATE IDS FOUND' && exit 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Assign globally unique numeric ids to every service definition.","Never copy a service file to create a variant without changing its id.","Audit the services directory during upgrades for leftovers."],"tags":["duplicate","service-registry","config"],"backgroundTag":"conflicting-config-options","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"}