{"record":{"id":"495b91b02ace3e21","repo":"elastic/elasticsearch","slug":"separator-must-not-be-null-name","errorCode":null,"errorMessage":"[separator] must not be null: [${name}]","messagePattern":"\\[separator\\] must not be null: \\[(.+?)\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/aggregations/src/main/java/org/elasticsearch/aggregations/bucket/adjacency/AdjacencyMatrixAggregationBuilder.java","lineNumber":170,"sourceCode":"        // internally we want to have a fixed order of filters, regardless of\n        // the order of the filters in the request\n        this.filters.sort(Comparator.comparing(KeyedFilter::key));\n    }\n\n    private AdjacencyMatrixAggregationBuilder setFiltersAsList(List<KeyedFilter> filters) {\n        this.filters = new ArrayList<>(filters);\n        // internally we want to have a fixed order of filters, regardless of\n        // the order of the filters in the request\n        this.filters.sort(Comparator.comparing(KeyedFilter::key));\n        return this;\n    }\n\n    /**\n     * Set the separator used to join pairs of bucket keys\n     */\n    public AdjacencyMatrixAggregationBuilder separator(String separator) {\n        if (separator == null) {\n            throw new IllegalArgumentException(\"[separator] must not be null: [\" + name + \"]\");\n        }\n        this.separator = separator;\n        return this;\n    }\n\n    /**\n     * Get the filters. This will be an unmodifiable map\n     */\n    public Map<String, QueryBuilder> filters() {\n        Map<String, QueryBuilder> result = Maps.newMapWithExpectedSize(this.filters.size());\n        for (KeyedFilter keyedFilter : this.filters) {\n            result.put(keyedFilter.key(), keyedFilter.filter());\n        }\n        return result;\n    }\n\n    @Override\n    protected AdjacencyMatrixAggregationBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws IOException {","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/aggregations/src/main/java/org/elasticsearch/aggregations/bucket/adjacency/AdjacencyMatrixAggregationBuilder.java#L152-L188","documentation":"Thrown by AdjacencyMatrixAggregationBuilder.separator(String) when the argument is null. The separator string is used to join pairs of bucket keys in the resulting matrix buckets; null would break key generation downstream, so the setter explicitly rejects it.","triggerScenarios":"Calling `.separator(null)` on an adjacency_matrix aggregation builder. Programmatic code passing a possibly-null variable without null-checking. Deserialization paths that resolve separator from an absent optional field as null.","commonSituations":"Wrapping an optional user input directly into separator() without defaulting. Refactoring that introduces a nullable source for the separator. Tests that pass null to verify behavior.","solutions":["Default to the standard separator (\"&\") when the input is null: `separator(s == null ? \"&\" : s)`.","Validate upstream that separator is non-null before calling the builder.","Use an Optional/Objects.requireNonNull on the source value with a sensible default."],"exampleFix":"// before\nbuilder.separator(maybeNull);\n// after\nimport java.util.Objects;\nbuilder.separator(Objects.requireNonNullElse(maybeNull, \"&\"));","handlingStrategy":"validation","validationCode":"String sep = Objects.requireNonNullElse(candidateSeparator, \"&\");\nbuilder.separator(sep);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default nullable separators to a known value before calling separator().","Use Objects.requireNonNullElse to coalesce nulls.","Reject null configuration values at the boundary."],"tags":["aggregations","adjacency-matrix","null-check","validation"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}