{"record":{"id":"f29d74d7c4dc6aef","repo":"junit-team/junit5","slug":"message","errorCode":null,"errorMessage":"${message}","messagePattern":"\\$\\{message\\}","errorType":"validation","errorClass":"PreconditionViolationException","httpStatus":null,"severity":"error","filePath":"junit-platform-commons/src/main/java/org/junit/platform/commons/util/Preconditions.java","lineNumber":373,"sourceCode":"\tpublic static String notBlank(@Nullable String str, Supplier<String> messageSupplier)\n\t\t\tthrows PreconditionViolationException {\n\n\t\tcondition(StringUtils.isNotBlank(str), messageSupplier);\n\t\treturn str;\n\t}\n\n\t/**\n\t * Assert that the supplied {@code predicate} is {@code true}.\n\t *\n\t * @param predicate the predicate to check\n\t * @param message precondition violation message\n\t * @throws PreconditionViolationException if the predicate is {@code false}\n\t * @see #condition(boolean, Supplier)\n\t */\n\t@Contract(\"false, _ -> fail\")\n\tpublic static void condition(boolean predicate, String message) throws PreconditionViolationException {\n\t\tif (!predicate) {\n\t\t\tthrow new PreconditionViolationException(message);\n\t\t}\n\t}\n\n\t/**\n\t * Assert that the supplied {@code predicate} is {@code true}.\n\t *\n\t * @param predicate the predicate to check\n\t * @param messageSupplier precondition violation message supplier\n\t * @throws PreconditionViolationException if the predicate is {@code false}\n\t */\n\t@Contract(\"false, _ -> fail\")\n\tpublic static void condition(boolean predicate, Supplier<String> messageSupplier)\n\t\t\tthrows PreconditionViolationException {\n\n\t\tif (!predicate) {\n\t\t\tthrow new PreconditionViolationException(messageSupplier.get());\n\t\t}\n\t}","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/junit-team/junit5/blob/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/Preconditions.java#L355-L391","documentation":"Generic PreconditionViolationException thrown by Preconditions.condition(boolean, String) when the boolean predicate is false. The literal message passed by the caller is used verbatim - it is not a JUnit-internal message. Hundreds of call sites use this method, so the exact meaning depends entirely on the calling context shown in the stack trace.","triggerScenarios":"Any internal JUnit call to Preconditions.condition(predicate, \"msg\") where predicate evaluates false - e.g. a public API called with an argument that violates a documented contract that this guard checks.","commonSituations":"Misuse of a JUnit public API (wrong selector, malformed unique ID, invalid filter); calling internal utility methods directly with bad inputs; extension/SPI implementations violating documented invariants.","solutions":["Read the message - it states the specific precondition that failed","Find the Preconditions.condition call site in the stack trace to see which contract was violated","Fix the caller to satisfy the documented precondition"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read the PreconditionViolationException message and the call site in the stack trace","Honour documented @param contracts on JUnit public APIs","Avoid calling org.junit.platform.commons.util internal classes directly"],"tags":["preconditions","validation","contract"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}