{"record":{"id":"b3a19f3b5c6a90a3","repo":"quarkusio/quarkus","slug":"etag-was-null","errorCode":null,"errorMessage":"ETag was null","messagePattern":"ETag was null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/RequestImpl.java","lineNumber":103,"sourceCode":"            if (tag.equals(eTag) || tag.getValue().equals(\"*\")) {\n                match = true;\n                break;\n            }\n        }\n        if (match) {\n            if (\"GET\".equals(httpMethod) || \"HEAD\".equals(httpMethod)) {\n                return Response.notModified(eTag);\n            }\n\n            return Response.status(Response.Status.PRECONDITION_FAILED).tag(eTag);\n        }\n        return null;\n    }\n\n    @Override\n    public Response.ResponseBuilder evaluatePreconditions(EntityTag eTag) {\n        if (eTag == null)\n            throw new IllegalArgumentException(\"ETag was null\");\n        Response.ResponseBuilder builder = null;\n        List<String> ifMatch = requestContext.getHttpHeaders().getRequestHeaders().get(HttpHeaders.IF_MATCH);\n        if (ifMatch != null && ifMatch.size() > 0) {\n            builder = ifMatch(convertEtag(ifMatch), eTag);\n        }\n        if (builder == null) {\n            List<String> ifNoneMatch = requestContext.getHttpHeaders().getRequestHeaders().get(HttpHeaders.IF_NONE_MATCH);\n            if (ifNoneMatch != null && ifNoneMatch.size() > 0) {\n                builder = ifNoneMatch(convertEtag(ifNoneMatch), eTag);\n            }\n        }\n        if (builder != null) {\n            builder.tag(eTag);\n        }\n        if (builder != null && varyHeader != null)\n            builder.header(HttpHeaders.VARY, varyHeader);\n        return builder;\n    }","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/RequestImpl.java#L85-L121","documentation":"RequestImpl.evaluatePreconditions(EntityTag) throws IllegalArgumentException when the supplied EntityTag is null, as required by JAX-RS. Conditional request evaluation (If-Match/If-None-Match) cannot proceed without an ETag value.","triggerScenarios":"Calling request.evaluatePreconditions(EntityTag) with an EntityTag that is null — typically the result of a failed lookup or an uncomputed ETag passed straight through.","commonSituations":"ETag generated conditionally (only when caching enabled) and then passed unconditionally; refactoring where the ETag variable became nullable; reading an ETag from a store that returned null.","solutions":["Ensure the EntityTag is non-null before calling, computing a default one if caching is disabled.","If the ETag is unknown, call the no-arg evaluatePreconditions() instead (which never throws).","Null-check and skip conditional evaluation, returning a plain Response."],"exampleFix":"// before\nResponse.ResponseBuilder rb = request.evaluatePreconditions(etag); // etag may be null\n// after\nResponse.ResponseBuilder rb = etag != null\n    ? request.evaluatePreconditions(etag)\n    : request.evaluatePreconditions();","handlingStrategy":"type-guard","validationCode":"if (etag == null) {\n    return request.evaluatePreconditions(); // never throws\n}","typeGuard":"boolean hasEtag(EntityTag t) {\n    return t != null;\n}","tryCatchPattern":"try {\n    return request.evaluatePreconditions(etag);\n} catch (IllegalArgumentException e) {\n    return request.evaluatePreconditions();\n}","preventionTips":["Never pass a possibly-null EntityTag to the single-arg overload","Use the no-arg evaluatePreconditions() when metadata is unknown","Compute a deterministic ETag (hash) when caching is enabled"],"tags":["jaxrs","resteasy-reactive","etag","conditional-request"],"backgroundTag":"null-etag-precondition","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"}