{"record":{"id":"b70b3a1836bd3677","repo":"elastic/elasticsearch","slug":"minimum-interval-must-be-one-of-allowed-interval","errorCode":null,"errorMessage":"minimum_interval must be one of [{ALLOWED_INTERVALS.values()}]","messagePattern":"minimum_interval must be one of \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/aggregations/src/main/java/org/elasticsearch/aggregations/bucket/histogram/AutoDateHistogramAggregationBuilder.java","lineNumber":171,"sourceCode":"    }\n\n    @Override\n    protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {\n        return new AutoDateHistogramAggregationBuilder(this, factoriesBuilder, metadata);\n    }\n\n    @Override\n    public String getType() {\n        return NAME;\n    }\n\n    public String getMinimumIntervalExpression() {\n        return minimumIntervalExpression;\n    }\n\n    public AutoDateHistogramAggregationBuilder setMinimumIntervalExpression(String minimumIntervalExpression) {\n        if (minimumIntervalExpression != null && ALLOWED_INTERVALS.containsValue(minimumIntervalExpression) == false) {\n            throw new IllegalArgumentException(\n                MINIMUM_INTERVAL_FIELD.getPreferredName() + \" must be one of [\" + ALLOWED_INTERVALS.values() + \"]\"\n            );\n        }\n        this.minimumIntervalExpression = minimumIntervalExpression;\n        return this;\n    }\n\n    public AutoDateHistogramAggregationBuilder setNumBuckets(int numBuckets) {\n        if (numBuckets <= 0) {\n            throw new IllegalArgumentException(NUM_BUCKETS_FIELD.getPreferredName() + \" must be greater than 0 for [\" + name + \"]\");\n        }\n        this.numBuckets = numBuckets;\n        return this;\n    }\n\n    @Override\n    public BucketCardinality bucketCardinality() {\n        return BucketCardinality.MANY;","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/aggregations/src/main/java/org/elasticsearch/aggregations/bucket/histogram/AutoDateHistogramAggregationBuilder.java#L153-L189","documentation":"Thrown by AutoDateHistogramAggregationBuilder.setMinimumIntervalExpression when the supplied value is non-null but not one of the allowed intervals. Allowed values are the strings in ALLOWED_INTERVALS: year, month, day, hour, minute, second. The minimum_interval caps the granularity the auto-calculator is allowed to use.","triggerScenarios":"Calling `setMinimumIntervalExpression(\"week\")`, `\"quarter\"`, `\"millisecond\"`, or any typo. Submitting a REST request with `\"minimum_interval\": \"weeks\"` (plural or wrong unit).","commonSituations":"Users assuming the auto_date_histogram supports the same intervals as the regular date_histogram (which allows more units like week, quarter, fiscal periods). Pluralization typos. Copy-paste from date_histogram configurations.","solutions":["Use one of the six allowed values: year, month, day, hour, minute, second.","Omit minimum_interval entirely if you want the aggregation to auto-select any granularity.","Validate the value client-side against the allowed set before submitting."],"exampleFix":"// before\n{\"auto_date_histogram\":{\"field\":\"@timestamp\",\"minimum_interval\":\"week\"}}\n// after\n{\"auto_date_histogram\":{\"field\":\"@timestamp\",\"minimum_interval\":\"day\"}}","handlingStrategy":"validation","validationCode":"Set<String> ALLOWED = Set.of(\"year\",\"month\",\"day\",\"hour\",\"minute\",\"second\");\nif (minimumInterval != null && !ALLOWED.contains(minimumInterval)) {\n  throw new IllegalArgumentException(\"minimum_interval must be one of \" + ALLOWED);\n}","typeGuard":"boolean isValidMinimumInterval(String s) {\n  return s == null || Set.of(\"year\",\"month\",\"day\",\"hour\",\"minute\",\"second\").contains(s);\n}","tryCatchPattern":null,"preventionTips":["Remember auto_date_histogram supports only 6 intervals (no week/quarter).","Validate against the allowed set before submitting.","Omit minimum_interval to let the aggregation auto-select."],"tags":["aggregations","auto-date-histogram","date","interval","validation"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}