{"record":{"id":"a8bd47e385657765","repo":"apereo/cas","slug":"provided-credentials-chain-is-empty-as-no-credenti","errorCode":null,"errorMessage":"Provided credentials chain is empty as no credentials have been collected","messagePattern":"Provided credentials chain is empty as no credentials have been collected","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/cas-server-core-authentication-api/src/main/java/org/apereo/cas/authentication/DefaultAuthenticationResultBuilder.java","lineNumber":59,"sourceCode":"                                                 final Map<String, List<Object>> principalAttributes) throws Throwable {\n        return principalElectionStrategy.nominate(new LinkedHashSet<>(authentications), principalAttributes);\n    }\n\n    @Override\n    public Optional<Authentication> getInitialAuthentication() {\n        if (this.authentications.isEmpty()) {\n            LOGGER.warn(\"Authentication chain is empty as no authentications have been collected\");\n        }\n\n        synchronized (this.authentications) {\n            return this.authentications.stream().findFirst();\n        }\n    }\n\n    @Override\n    public Optional<Credential> getInitialCredential() {\n        if (this.providedCredentials.isEmpty()) {\n            LOGGER.warn(\"Provided credentials chain is empty as no credentials have been collected\");\n        }\n        return providedCredentials.stream().findFirst();\n    }\n\n    @Override\n    @CanIgnoreReturnValue\n    public AuthenticationResultBuilder collect(final Authentication authentication) {\n        Optional.ofNullable(authentication).ifPresent(authentications::add);\n        return this;\n    }\n\n    @Override\n    @CanIgnoreReturnValue\n    public AuthenticationResultBuilder collect(final Collection<Authentication> authentications) {\n        this.authentications.addAll(authentications);\n        return this;\n    }\n","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/core/cas-server-core-authentication-api/src/main/java/org/apereo/cas/authentication/DefaultAuthenticationResultBuilder.java#L41-L77","documentation":"DefaultAuthenticationResultBuilder.getInitialCredential logs a warning when the provided credentials collection is empty, then returns Optional.empty(). It mirrors error 364 but for credentials rather than authentications.","triggerScenarios":"getInitialCredential() called on a builder whose providedCredentials were never populated (transaction submission path never called collect/credential capture).","commonSituations":"Custom webflow actions constructing AuthenticationResultBuilder manually; flows re-entered after credential capture step was skipped; tests instantiating DefaultAuthenticationResultBuilder without credentials.","solutions":["Populate the builder with the initial credential(s) from the authentication transaction before reading them back.","Check the webflow state that captures credentials executed (submit/initial flow actions).","Handle Optional.empty() defensively when the initial credential is legitimately optional in your flow."],"exampleFix":"// before\nval cred = resultBuilder.getInitialCredential(); // empty\n// after\nresultBuilder.collect(transaction.getCredentials());\nval cred = resultBuilder.getInitialCredential();","handlingStrategy":"type-guard","validationCode":"if (resultBuilder.getInitialCredential().isEmpty()) {\n    // credentials never captured — send user back to the credential step\n}","typeGuard":"Optional<Credential> maybeCred = resultBuilder.getInitialCredential();\nif (maybeCred.isPresent()) {\n    Credential c = maybeCred.get();\n    // safe use\n}","tryCatchPattern":null,"preventionTips":["Collect credentials into the builder immediately after form submission.","Add flow guards that verify credentials exist before dependent states."],"tags":["authentication","credentials","empty-state"],"backgroundTag":"empty-result-set","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"}