{"record":{"id":"61ad5b67f7fdb905","repo":"elastic/elasticsearch","slug":"bitmap-terms-value-cannot-be-null","errorCode":null,"errorMessage":"[bitmap_terms] value cannot be null","messagePattern":"\\[bitmap_terms\\] value cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/bitmap/src/main/java/org/elasticsearch/index/query/bitmapterms/BitmapTermsQueryBuilder.java","lineNumber":67,"sourceCode":" *   }\n * }\n * }</pre>\n */\npublic class BitmapTermsQueryBuilder extends LeafQueryBuilder<BitmapTermsQueryBuilder> {\n\n    public static final String NAME = \"bitmap_terms\";\n\n    static final TransportVersion BITMAP_TERMS_QUERY_ADDED = TransportVersion.fromName(\"bitmap_terms_query_added\");\n\n    private final String fieldName;\n    private final String value;\n\n    public BitmapTermsQueryBuilder(String fieldName, String value) {\n        if (fieldName == null || fieldName.isBlank()) {\n            throw new IllegalArgumentException(\"[bitmap_terms] field name cannot be null or empty\");\n        }\n        if (value == null) {\n            throw new IllegalArgumentException(\"[bitmap_terms] value cannot be null\");\n        }\n        this.fieldName = fieldName;\n        this.value = value;\n    }\n\n    public BitmapTermsQueryBuilder(StreamInput in) throws IOException {\n        super(in);\n        this.fieldName = in.readString();\n        this.value = in.readString();\n    }\n\n    @Override\n    protected void doWriteTo(StreamOutput out) throws IOException {\n        out.writeString(fieldName);\n        out.writeString(value);\n    }\n\n    public String fieldName() {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/bitmap/src/main/java/org/elasticsearch/index/query/bitmapterms/BitmapTermsQueryBuilder.java#L49-L85","documentation":"BitmapTermsQueryBuilder constructor's second precondition: the value parameter must not be null (empty string is allowed; only null is rejected). Throws IllegalArgumentException immediately when value == null. Note fieldName is checked first, so a null field surfaces the 1058 message instead.","triggerScenarios":"Constructing a BitmapTermsQueryBuilder with a non-blank field but a null value: new BitmapTermsQueryBuilder(\"f\", null); or a REST request like {\"bitmap_terms\": {\"field\": \"f\"}} with no 'value' key.","commonSituations":"Passing through an unvalidated user input that may be null; missing 'value' key in JSON; conditional logic that forgot to default the value.","solutions":["Always pass a non-null value (use \"\" if an empty match is genuinely intended, though that is rarely useful).","Validate at the application boundary that value is non-null before constructing the query.","For REST requests, ensure the 'value' key is present in the bitmap_terms body."],"exampleFix":"// before\nnew BitmapTermsQueryBuilder(\"category_id\", null)\n// after\nString v = userInput == null ? \"\" : userInput;\nnew BitmapTermsQueryBuilder(\"category_id\", v);","handlingStrategy":"type-guard","validationCode":"static String requireValue(String v) {\n  if (v == null) throw new IllegalArgumentException(\"value required\");\n  return v;\n}","typeGuard":"// Narrow to a non-null value before constructing the query\nstatic boolean isUsableValue(String v) {\n  return v != null;\n}","tryCatchPattern":null,"preventionTips":["Default user-supplied values to \"\" (or reject them) before constructing the query — null is the only rejected value.","Schema-check REST bodies for the presence of the 'value' key on bitmap_terms."],"tags":["bitmap","query","validation","constructor"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}