{"record":{"id":"7981e8e51a8d6633","repo":"elastic/elasticsearch","slug":"size-must-be-greater-than-0-found-size-in","errorCode":null,"errorMessage":"[size] must be greater than 0. Found [{size}] in [{name}]","messagePattern":"\\[size\\] must be greater than 0\\. Found \\[(.+?)\\] in \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/aggregations/src/main/java/org/elasticsearch/aggregations/bucket/timeseries/TimeSeriesAggregationBuilder.java","lineNumber":131,"sourceCode":"\n    @Override\n    public BucketCardinality bucketCardinality() {\n        return BucketCardinality.MANY;\n    }\n\n    @Override\n    public String getType() {\n        return NAME;\n    }\n\n    @Override\n    public boolean isInSortOrderExecutionRequired() {\n        return true;\n    }\n\n    public TimeSeriesAggregationBuilder setSize(int size) {\n        if (size <= 0) {\n            throw new IllegalArgumentException(\"[size] must be greater than 0. Found [\" + size + \"] in [\" + name + \"]\");\n        }\n        this.size = size;\n        return this;\n    }\n\n    public int getSize() {\n        return size;\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (this == o) return true;\n        if (o == null || getClass() != o.getClass()) return false;\n        if (super.equals(o) == false) return false;\n        TimeSeriesAggregationBuilder that = (TimeSeriesAggregationBuilder) o;\n        return keyed == that.keyed && size == that.size;\n    }\n","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/aggregations/src/main/java/org/elasticsearch/aggregations/bucket/timeseries/TimeSeriesAggregationBuilder.java#L113-L149","documentation":"Thrown by TimeSeriesAggregationBuilder.setSize when size <= 0. The time_series aggregation groups documents into time-series buckets and requires a positive size to bound the number of series tracked. Zero or negative is meaningless for the internal data structures.","triggerScenarios":"Calling setSize(0) or setSize(-1) on a time_series aggregation. Submitting a REST request with `\"size\": 0`. Defaulting size from a configuration variable that was initialized to zero.","commonSituations":"Misconfigured index mapping time_series dimension. Tests or tooling that pass zero as a boundary value. Pipelines that compute size dynamically and hit a zero edge case.","solutions":["Set size to a positive integer reflecting the maximum number of time series to track.","Validate that any computed size is >= 1 before calling setSize.","Default to a reasonable positive value (e.g. the documented default) when input is absent or zero."],"exampleFix":"// before\n{\"time_series\":{\"size\":0,...}}\n// after\n{\"time_series\":{\"size\":10000,...}}","handlingStrategy":"validation","validationCode":"if (size <= 0) {\n  throw new IllegalArgumentException(\"time_series size must be > 0\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default computed sizes to a positive integer.","Validate configuration variables for positivity before setSize.","Treat zero as unset and substitute a sensible default."],"tags":["aggregations","time-series","validation","bounds"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}