{"record":{"id":"1ce6460f08a8ee4e","repo":"apereo/cas","slug":"attribute-definition-contains-a-key-property","errorCode":null,"errorMessage":"Attribute definition contains a key property [{}] that differs from its registering key [{}]. This is likely due to misconfiguration of the attribute definition, and CAS will use the key property [{}] to register the attribute definition in the attribute store","messagePattern":"Attribute definition contains a key property \\[(.+?)\\] that differs from its registering key \\[(.+?)\\]\\. This is likely due to misconfiguration of the attribute definition, and CAS will use the key property \\[(.+?)\\] to register the attribute definition in the attribute store","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/cas-server-core-authentication-api/src/main/java/org/apereo/cas/authentication/attribute/AbstractAttributeDefinitionStore.java","lineNumber":70,"sourceCode":"    @Getter\n    private String scope = StringUtils.EMPTY;\n\n    protected AbstractAttributeDefinitionStore(final AttributeDefinition... definitions) {\n        Arrays.stream(definitions).forEach(this::registerAttributeDefinition);\n    }\n\n    /**\n     * Register attribute definitions.\n     *\n     * @param entries the entries\n     */\n    public void registerAttributeDefinitions(final Map<String, AttributeDefinition> entries) {\n        entries.forEach(this::registerAttributeDefinition);\n    }\n\n    private static String getAttributeDefinitionKey(final String key, final AttributeDefinition definition) {\n        if (StringUtils.isNotBlank(definition.getKey()) && !Strings.CI.equals(definition.getKey(), key)) {\n            LOGGER.warn(\"Attribute definition contains a key property [{}] that differs from its registering key [{}]. \"\n                + \"This is likely due to misconfiguration of the attribute definition, and CAS will use the key property [{}] \"\n                + \"to register the attribute definition in the attribute store\", definition.getKey(), key, definition.getKey());\n            return definition.getKey();\n        }\n        return key;\n    }\n\n    @Override\n    @CanIgnoreReturnValue\n    public AttributeDefinitionStore registerAttributeDefinition(final AttributeDefinition definition) {\n        return registerAttributeDefinition(definition.getKey(), definition);\n    }\n\n    @Override\n    @CanIgnoreReturnValue\n    public AttributeDefinitionStore registerAttributeDefinition(final String key, final AttributeDefinition definition) {\n        LOGGER.trace(\"Registering attribute definition [{}] by key [{}]\", definition, key);\n        val keyToUse = getAttributeDefinitionKey(key, definition);","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/core/cas-server-core-authentication-api/src/main/java/org/apereo/cas/authentication/attribute/AbstractAttributeDefinitionStore.java#L52-L88","documentation":"AbstractAttributeDefinitionStore.registerAttributeDefinition detected that an AttributeDefinition's 'key' property differs from the map key under which it was registered. CAS warns that this is likely misconfiguration and resolves the conflict by preferring the definition's key property when storing the attribute.","triggerScenarios":"Calling registerAttributeDefinitions with a map where map-key != definition.getKey() (e.g., JSON/Groovy attribute definitions where the 'key' field doesn't match the outer entry name).","commonSituations":"Hand-edited attribute definition JSON with mismatched entry name and key property; copy-pasted definition renamed only on the outside; programmatic registration using a different map key.","solutions":["Align the definition's key property with the registering map key so the warning disappears","If the inner key is intentional, accept the warning — CAS will use the inner key in the attribute store","Review generated/default definition files after upgrades for key/entry mismatches"],"exampleFix":"// before (JSON attribute definitions)\n\"email\": { \"key\": \"mail\" }\n// after\n\"email\": { \"key\": \"email\" }","handlingStrategy":"validation","validationCode":"entries.forEach((k, def) -> { if (def.getKey() != null && !def.getKey().equalsIgnoreCase(k)) throw new IllegalStateException(\"key mismatch for \" + k); });","typeGuard":"boolean keysMatch(String registeringKey, AttributeDefinition def) { return def.getKey() == null || def.getKey().isBlank() || def.getKey().equalsIgnoreCase(registeringKey); }","tryCatchPattern":null,"preventionTips":["Validate attribute definition files at build time","Keep entry name and key property identical by convention","Run schema/lint checks on definition JSON after edits"],"tags":["attribute-definition","misconfiguration","attribute-resolution","naming-conflict"],"backgroundTag":"invalid-config-value","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"}