{"record":{"id":"b7614219c139b4cf","repo":"quarkusio/quarkus","slug":"bad-pet","errorCode":null,"errorMessage":"bad pet","messagePattern":"bad pet","errorType":"http","errorClass":"IllegalArgumentException","httpStatus":500,"severity":"error","filePath":"integration-tests/reactive-messaging-hibernate-orm/src/main/java/io/quarkus/it/kafka/pet/PetProducer.java","lineNumber":28,"sourceCode":"import io.smallrye.mutiny.Uni;\nimport io.smallrye.reactive.messaging.kafka.transactions.KafkaTransactions;\n\n@Path(\"/kafka\")\npublic class PetProducer {\n\n    @Channel(\"pets\")\n    KafkaTransactions<Pet> emitter;\n\n    @POST\n    @Path(\"/pets\")\n    @Transactional\n    public void post(String name) {\n        Log.infov(\"Sending pet {0}\", name);\n        Pet pet = new Pet(name);\n        emitter.withTransaction(e -> {\n            pet.persist();\n            if (pet.name.equals(\"bad\")) {\n                throw new IllegalArgumentException(\"bad pet\");\n            }\n            Log.infov(\"Persisted pet {0}\", pet);\n            e.send(pet);\n            return Uni.createFrom().voidItem();\n        }).await().indefinitely();\n    }\n}\n","sourceCodeStart":10,"sourceCodeEnd":36,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/reactive-messaging-hibernate-orm/src/main/java/io/quarkus/it/kafka/pet/PetProducer.java#L10-L36","documentation":"An IllegalArgumentException with message 'bad pet' is thrown inside the reactive messaging transaction of PetProducer.post when the pet name equals 'bad'. The pet is persisted within an emitter.withTransaction block and the exception rolls back the transaction, letting tests verify that Hibernate ORM transactions integrated with Kafka emitters are rolled back and the Kafka message is not sent.","triggerScenarios":"POST to the pets endpoint with body 'bad' — pet.persist() succeeds but the exception aborts the withTransaction callback before e.send(pet), rolling back the DB insert.","commonSituations":"Testing the reactive-messaging-hibernate-orm integration (rollback semantics); a user posting a pet literally named 'bad' to a deployed instance will always get this failure.","solutions":["Post a pet name other than 'bad' to avoid the intentional rollback path.","If seen in tests, it is expected — assert the DB has no persisted 'bad' pet and no Kafka message was produced.","If persistence should succeed despite the marker name, remove/adjust the equality check or rename the sentinel value.","Handle the failure on the caller side (onFailure) only if you explicitly intend to swallow the rollback."],"exampleFix":"// before\nif (pet.name.equals(\"bad\")) {\n    throw new IllegalArgumentException(\"bad pet\");\n}\n// after (guard at the resource level instead)\nif (\"bad\".equals(name)) {\n    return Response.status(400).entity(\"invalid pet name\").build();\n}","handlingStrategy":"validation","validationCode":"if (\"bad\".equals(name)) {\n    // sentinel name: transaction will roll back and no Kafka message is sent\n    return Response.status(400).entity(\"invalid pet name\").build();\n}","typeGuard":"boolean isSafePetName(String name) {\n    return name != null && !\"bad\".equals(name);\n}","tryCatchPattern":"try {\n    emitter.withTransaction(e -> { pet.persist(); e.send(pet); return Uni.createFrom().voidItem(); })\n          .await().indefinitely();\n} catch (IllegalArgumentException e) {\n    if (\"bad pet\".equals(e.getMessage())) {\n        // transaction rolled back; message not published — expected sentinel path\n    }\n    throw e;\n}","preventionTips":["Validate pet names at the REST boundary before entering the transactional producer.","Remember persist() inside withTransaction rolls back when the callback throws.","In tests, assert both DB state and Kafka (no record for the rolled-back pet).","Avoid sentinel magic names in production; prefer explicit error responses."],"tags":["kafka","hibernate-orm","transaction-rollback","reactive-messaging"],"backgroundTag":"transaction-rollback-failure","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"}