{"record":{"id":"fa0f2702eab2342c","repo":"apereo/cas","slug":"no-recipient-is-provided-with-a-valid-email-phone","errorCode":null,"errorMessage":"No recipient is provided with a valid email/phone for %s","messagePattern":"No recipient is provided with a valid email/phone for (.+?)","errorType":"http","errorClass":null,"httpStatus":422,"severity":"warning","filePath":"support/cas-server-support-pm-webflow/src/main/java/org/apereo/cas/pm/web/PasswordManagementEndpoint.java","lineNumber":166,"sourceCode":"     *\n     * @return the response entity\n     */\n    @Operation(summary = \"Initiate a password reset operation and notify the user\",\n        parameters = {\n            @Parameter(name = \"username\", description = \"The username to reset the password for\"),\n            @Parameter(name = \"service\", description = \"The service requesting the password reset\")\n        })\n    @PostMapping(path = \"/reset/requests/{username}\", produces = MediaType.APPLICATION_JSON_VALUE)\n    public ResponseEntity passwordReset(@PathVariable final String username,\n                                        @RequestParam(\"service\") final String service,\n                                        final HttpServletRequest request) throws Throwable {\n        val query = PasswordManagementQuery.builder().username(username).build();\n\n        val emails = passwordManagementService.getObject().findEmails(query);\n        val phone = passwordManagementService.getObject().findPhone(query);\n        if (emails.isEmpty() && StringUtils.isBlank(phone)) {\n            val message = \"No recipient is provided with a valid email/phone for %s\".formatted(username);\n            LOGGER.warn(message);\n            return ResponseEntity.unprocessableContent().body(message);\n        }\n\n        val webApplicationService = serviceFactory.getObject().createService(service);\n        val registeredService = servicesManager.getObject().findServiceBy(webApplicationService);\n        val principal = resolvedPrincipal(username);\n\n        val audit = AuditableContext.builder()\n            .registeredService(registeredService)\n            .service(webApplicationService)\n            .principal(principal)\n            .httpRequest(request)\n            .build();\n        val accessResult = registeredServiceAccessStrategyEnforcer.getObject().execute(audit);\n        accessResult.throwExceptionIfNeeded();\n\n        val url = passwordResetUrlBuilder.getObject().build(username, webApplicationService);\n        val pm = casProperties.getAuthn().getPm();","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/support/cas-server-support-pm-webflow/src/main/java/org/apereo/cas/pm/web/PasswordManagementEndpoint.java#L148-L184","documentation":"REST endpoint PasswordManagementEndpoint.passwordReset resolves the user's email addresses and phone from the configured password-management service. If both come back empty it logs this warn and returns HTTP 422 (Unprocessable Content) with the message, refusing to generate a reset link because there is nowhere to send it.","triggerScenarios":"passwordManagementService.findEmails(query) returns an empty set AND findPhone(query) returns null/blank for the submitted username — i.e. the configured mail/sms attributes are absent or invalid in the backend for that user.","commonSituations":"User has no mail/mobile attributes in LDAP; PM mail attribute misconfigured; PM service is the no-op or LDAP search returns no entry; calling the REST endpoint directly during integration testing with test users lacking contact attributes.","solutions":["Populate a valid mail (and/or phone) attribute for the user in the backend store","Verify cas.authn.pm.reset.mail.attributeName and sms.attributeName match real populated attributes","Check upstream warns from findEmails/findAttribute (invalid email / missing LDAP attribute) to see which check failed","For programmatic flows, handle the 422 response and prompt for an alternate contact or admin-assisted reset"],"exampleFix":"// before — user entry lacks mail\n// HTTP 422 No recipient is provided with a valid email/phone for jsmith\n// after — populate LDAP: mail: jsmith@example.com\n// endpoint then returns 200 with reset instructions sent","handlingStrategy":"validation","validationCode":"if (emails.isEmpty() && StringUtils.isBlank(phone)) {\n    // handle HTTP 422 Unprocessable Content from PasswordManagementEndpoint\n    promptForAlternateContact(username);\n}","typeGuard":null,"tryCatchPattern":"ResponseEntity<String> r = restTemplate.postForEntity(resetUrl, req, String.class);\nif (r.getStatusCode().value() == 422) {\n    log.warn(\"No valid recipient for reset: {}\", r.getBody());\n}","preventionTips":["Provision every account with at least one valid email or phone","Test the reset endpoint with real directory users before go-live","Surface this 422 to admins as a data-quality issue, not a CAS bug"],"tags":["password-reset","rest-endpoint","email","missing-attribute"],"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"}