apereo/cas · warning
Requested attribute [ ] could not be found in the query…
Error message
Requested attribute [{}] could not be found in the query results What it means
This WARN is logged by AbstractJdbcUsernamePasswordAuthenticationHandler.collectPrincipalAttributes when an attribute name listed in the SQL query's attribute-mapping configuration is absent from the query result row. CAS iterates the expected attribute names, and any name with no corresponding column/value in the ResultSet is reported and simply skipped - the returned principal just lacks that attribute. It signals a mismatch between configured attribute mappings and what the SQL query actually returns.
Solutions
- Align the sql SELECT clause with the configured attributeMappings so every mapped attribute (and its source key) is actually returned by the query
- Fix typos or case mismatches between attributeMappings keys and result-set column names/aliases
- If the attribute is legitimately optional per user, ignore the warning or coalesce the column in SQL (e.g. COALESCE(col, ''))
- Verify the principal's row exists and is not missing joined data for the specific user
Example fix
// before sql=SELECT username, email FROM users WHERE username=? attributeMappings.email=mail attributeMappings.displayName=displayName // after sql=SELECT username, email, display_name FROM users WHERE username=? attributeMappings.email=mail attributeMappings.displayName=displayName
Defensive patterns
Strategy: validation
Validate before calling
Set<String> selectAliases = extractSelectAliases(properties.getSql());
for (String attr : properties.getAttributeMappings().keySet()) {
if (!selectAliases.contains(attr)) throw new IllegalStateException("attributeMappings key not in SELECT: " + attr);
} Prevention
- Keep attributeMappings and the sql SELECT clause in sync; review both together in code review
- Use explicit column aliases in SQL matching config keys exactly
- Test authentication for users with NULL/optional columns
- Add startup validation that parsed query columns cover all mapped attributes
When it happens
Trigger: Configuring cas.authn.jdbc.query[].attributeMappings whose keys/values reference columns not selected by the configured sql statement; virtual attribute remapping (names) pointing at a source attribute that the query did not return; renaming a DB column without updating attributeMappings; sql returning a single-row result missing expected fields due to NULL or join misses.
Common situations: Typo in attributeMappings vs actual SELECT column aliases; DBA added a column but forgot to add it to the SQL; empty/NULL result columns for some users; migrating from another authn handler whose attribute names differed.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- [e.getMessage()]
- Password does not match value on record.
- Password does not match value on record.
- Password has expired
- [username] not found with SQL query.
AI-assisted analysis of apereo/cas@e7288fc434 (2026-09-08).
Data as JSON: /api/errors/59f1b0577a678b66.
Report an issue: GitHub.
Appendix: source
Thrown at support/cas-server-support-jdbc-authentication/src/main/java/org/apereo/cas/jdbc/AbstractJdbcUsernamePasswordAuthenticationHandler.java:58
this.dataSource = dataSource;
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
}
protected Map<String, List<Object>> collectPrincipalAttributes(final Map<String, Object> dbFields) {
val attributes = new HashMap<String, List<Object>>();
val principalAttributeMap = CoreAuthenticationUtils.transformPrincipalAttributesListIntoMultiMap(properties.getPrincipalAttributeList());
principalAttributeMap.forEach((key, names) -> {
val attribute = dbFields.get(key);
if (attribute != null) {
LOGGER.debug("Found attribute [{}] from the query results", key);
val attributeNames = CollectionUtils.toCollection(names);
attributeNames.forEach(attrName -> {
LOGGER.debug("Principal attribute [{}] is virtually remapped/renamed to [{}]", key, attrName);
attributes.put(attrName.toString(), CollectionUtils.wrap(attribute.toString()));
});
} else {
LOGGER.warn("Requested attribute [{}] could not be found in the query results", key);
}
});
return attributes;
}
}
View on GitHub (pinned to e7288fc434)