{"record":{"id":"46a772289e337f2f","repo":"quarkusio/quarkus","slug":"the-mails-parameter-must-not-be-null","errorCode":null,"errorMessage":"The `mails` parameter must not be `null`","messagePattern":"The `mails` parameter must not be `null`","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"extensions/mailer/runtime/src/main/java/io/quarkus/mailer/runtime/MutinyMailerImpl.java","lineNumber":78,"sourceCode":"    MutinyMailerImpl(Vertx vertx, MailClient client, MockMailboxImpl mockMailbox,\n            String from, String bounceAddress, boolean mock, List<Pattern> approvedRecipients,\n            boolean logRejectedRecipients, boolean logInvalidRecipients, Event<SentMail> sentEmailEvent) {\n        this.vertx = vertx;\n        this.client = client;\n        this.mockMailbox = mockMailbox;\n        this.from = from;\n        this.bounceAddress = bounceAddress;\n        this.mock = mock;\n        this.approvedRecipients = approvedRecipients;\n        this.logRejectedRecipients = logRejectedRecipients;\n        this.logInvalidRecipients = logInvalidRecipients;\n        this.sentEmailEvent = sentEmailEvent;\n    }\n\n    @Override\n    public Uni<Void> send(Mail... mails) {\n        if (mails == null) {\n            throw new IllegalArgumentException(\"The `mails` parameter must not be `null`\");\n        }\n\n        List<Uni<Void>> unis = stream(mails)\n                .map(new Function<Mail, Uni<Void>>() {\n                    @Override\n                    public Uni<Void> apply(Mail mail) {\n                        return MutinyMailerImpl.this.toMailMessage(mail)\n                                .chain(new Function<MailMessage, Uni<? extends Void>>() {\n                                    @Override\n                                    public Uni<? extends Void> apply(MailMessage mailMessage) {\n                                        return send(mail, mailMessage);\n                                    }\n                                });\n                    }\n                })\n                .collect(Collectors.toList());\n\n        return Uni.combine().all().unis(unis).discardItems();","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/mailer/runtime/src/main/java/io/quarkus/mailer/runtime/MutinyMailerImpl.java#L60-L96","documentation":"MutinyMailerImpl.send(Mail... mails) accepts a varargs array of Mail objects. A null array reference cannot be iterated, so the method immediately rejects it with this IllegalArgumentException before doing any work.","triggerScenarios":"Calling reactiveMailer.send((Mail[]) null) or passing a null Mail[] variable into send(); generic code that forwards a nullable array parameter directly to the mailer.","commonSituations":"Building a Mail[] from a nullable collection with toArray on a null list; reflection or framework code supplying null varargs; confusing send(Mail...) with send(Mail) and passing null intending a single null mail.","solutions":["Never pass a null array — pass an empty array or skip the call when there is nothing to send.","Null-check the array at the call site before invoking send().","If sending one message, construct it explicitly: reactiveMailer.send(Mail.withText(to, subject, body))."],"exampleFix":"// before\nreactiveMailer.send(mails); // mails may be null\n\n// after\nif (mails != null && mails.length > 0) {\n    reactiveMailer.send(mails);\n}","handlingStrategy":"type-guard","validationCode":"if (mails == null || mails.length == 0) {\n    LOG.info(\"Nothing to send\");\n    return Uni.createFrom().voidItem();\n}","typeGuard":"static boolean isSendable(Mail[] mails) {\n    return mails != null && mails.length > 0 && Arrays.stream(mails).allMatch(Objects::nonNull);\n}","tryCatchPattern":"try {\n    reactiveMailer.send(mails).await().indefinitely();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"must not be `null`\")) {\n        LOG.error(\"send() was called with a null Mail array\", e);\n    }\n    throw e;\n}","preventionTips":["Wrap send() in your own helper that rejects null/empty input","Never pass varargs from nullable collections without a null check","Prefer sending a single Mail object over building arrays when possible"],"tags":["quarkus","mailer","null-argument","illegal-argument","api-misuse"],"backgroundTag":"null-argument-rejected","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}