{"record":{"id":"0e4cf9158c981869","repo":"elastic/elasticsearch","slug":"from-must-be-a-non-negative-integer-from","errorCode":null,"errorMessage":"[from] must be a non-negative integer: [{from}]","messagePattern":"\\[from\\] must be a non-negative integer: \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/aggregations/src/main/java/org/elasticsearch/aggregations/pipeline/BucketSortPipelineAggregationBuilder.java","lineNumber":112,"sourceCode":"    public BucketSortPipelineAggregationBuilder(StreamInput in) throws IOException {\n        super(in, NAME);\n        sorts = in.readCollectionAsList(FieldSortBuilder::new);\n        from = in.readVInt();\n        size = in.readOptionalVInt();\n        gapPolicy = GapPolicy.readFrom(in);\n    }\n\n    @Override\n    protected void doWriteTo(StreamOutput out) throws IOException {\n        out.writeCollection(sorts);\n        out.writeVInt(from);\n        out.writeOptionalVInt(size);\n        gapPolicy.writeTo(out);\n    }\n\n    public BucketSortPipelineAggregationBuilder from(int from) {\n        if (from < 0) {\n            throw new IllegalArgumentException(\"[\" + FROM.getPreferredName() + \"] must be a non-negative integer: [\" + from + \"]\");\n        }\n        this.from = from;\n        return this;\n    }\n\n    public BucketSortPipelineAggregationBuilder size(Integer size) {\n        if (size != null && size <= 0) {\n            throw new IllegalArgumentException(\"[\" + SIZE.getPreferredName() + \"] must be a positive integer: [\" + size + \"]\");\n        }\n        this.size = size;\n        return this;\n    }\n\n    public BucketSortPipelineAggregationBuilder gapPolicy(GapPolicy gapPolicy) {\n        if (gapPolicy == null) {\n            throw new IllegalArgumentException(\"[\" + GAP_POLICY.getPreferredName() + \"] must not be null: [\" + name + \"]\");\n        }\n        this.gapPolicy = gapPolicy;","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/aggregations/src/main/java/org/elasticsearch/aggregations/pipeline/BucketSortPipelineAggregationBuilder.java#L94-L130","documentation":"Error \"[from] must be a non-negative integer: [{from}]\" thrown in elastic/elasticsearch.","triggerScenarios":"Thrown at modules/aggregations/src/main/java/org/elasticsearch/aggregations/pipeline/BucketSortPipelineAggregationBuilder.java:112 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}