{"record":{"id":"f33f42673f89755c","repo":"theonedev/onedev","slug":"invalid-id-specified-in-recipient-address","errorCode":null,"errorMessage":"Invalid id specified in recipient address: ","messagePattern":"Invalid id specified in recipient address: ","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/mail/DefaultMailService.java","lineNumber":489,"sourceCode":"\t\t\t\t\t\t\tvar serviceDeskSetting = settingService.getServiceDeskSetting();\n\t\t\t\t\t\t\tif (serviceDeskSetting != null) {\n\t\t\t\t\t\t\t\tlogger.debug(\"Creating issue via email (project: {})...\", project.getPath());\n\t\t\t\t\t\t\t\tinvolvedIssue = openIssue(message, project, fromInternetAddress, fromUser, parsedSystemAddress, receiverInternetAddresses);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Unable to create issue from email as service desk is not enabled\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (parsedReceiverAddress.isSubaddress() && systemAddress.equalsIgnoreCase(parsedReceiverAddress.getOriginalAddress())) {\n\t\t\t\t\t\tif (involvedIssue == null && involvedPullRequest == null) {\n\t\t\t\t\t\t\tString subAddress = StringUtils.substringAfter(parsedReceiverAddress.getName(), \"+\");\n\t\t\t\t\t\t\tif (subAddress.equals(MailService.TEST_SUB_ADDRESS)) {\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t} else if (subAddress.contains(\"~\")) {\n\t\t\t\t\t\t\t\tLong entityId;\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tentityId = Long.parseLong(StringUtils.substringAfter(subAddress, \"~\"));\n\t\t\t\t\t\t\t\t} catch (NumberFormatException e) {\n\t\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Invalid id specified in recipient address: \" + parsedReceiverAddress);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (subAddress.contains(\"issue\")) {\n\t\t\t\t\t\t\t\t\tinvolvedIssue = issueService.get(entityId);\n\t\t\t\t\t\t\t\t\tif (involvedIssue == null)\n\t\t\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Non-existent issue specified in recipient address: \" + parsedReceiverAddress);\n\t\t\t\t\t\t\t\t\tif (subAddress.contains(\"unsubscribe\")) {\n\t\t\t\t\t\t\t\t\t\tif (fromUser != null) {\n\t\t\t\t\t\t\t\t\t\t\tvar watch = issueWatchService.find(involvedIssue, fromUser);\n\t\t\t\t\t\t\t\t\t\t\tif (watch != null) \n\t\t\t\t\t\t\t\t\t\t\t\twatch.setWatching(false);\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tinvolvedIssue.getExternalParticipants().remove(fromInternetAddress);\n\t\t\t\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tString subject = \"Unsubscribed successfully from issue \" + involvedIssue.getReference();\n\t\t\t\t\t\t\t\t\t\tString template = settingService.getEmailTemplates().getIssueNotificationUnsubscribed();\n\n\t\t\t\t\t\t\t\t\t\tMap<String, Object> bindings = new HashMap<>();\n\t\t\t\t\t\t\t\t\t\tbindings.put(\"issue\", involvedIssue);","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/mail/DefaultMailService.java#L471-L507","documentation":"Emails can address entities via subaddressing like issue~123@system. handleMessage parses the part after '~' as a Long entity id; if it is not numeric, an ExplicitException 'Invalid id specified in recipient address: <address>' is thrown.","triggerScenarios":"Email recipient subaddress contains '~' but the text after it cannot be parsed as a Long, e.g. issue~abc@company.com or pullrequest~1x@company.com.","commonSituations":"Hand-typed or mistyped subaddress in the To field; broken bookmark/mail template embedding a wrong id; copied address truncated or edited.","solutions":["Correct the recipient address so the part after '~' is a numeric id (e.g. issue~42@...).","Copy the entity address from the OneDev UI instead of typing it.","If generating addresses programmatically, validate the id with Long.parseLong before composing the address."],"exampleFix":"// before\nTo: issue~abc@company.onedev.io\n// after\nTo: issue~42@company.onedev.io","handlingStrategy":"validation","validationCode":"String sub = StringUtils.substringAfter(address, \"~\");\nboolean ok = sub.matches(\"\\\\d+\");","typeGuard":"boolean hasValidEntityId(String subAddress) { try { Long.parseLong(StringUtils.substringAfter(subAddress, \"~\")); return true; } catch (NumberFormatException e) { return false; } }","tryCatchPattern":"try { handleMessage(message); } catch (ExplicitException e) { bounceToSender(e.getMessage()); }","preventionTips":["Copy entity addresses from the UI, never type them","Validate ids when generating addresses programmatically","Bounce malformed addresses with a helpful message"],"tags":["email","subaddress","parsing"],"backgroundTag":"invalid-identifier-format","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}