{"record":{"id":"e79333ea841ff6d3","repo":"elastic/elasticsearch","slug":"cancelled-e79333","errorCode":null,"errorMessage":"Cancelled","messagePattern":"Cancelled","errorType":"exception","errorClass":"TaskCancelledException","httpStatus":null,"severity":"error","filePath":"modules/aggregations/src/main/java/org/elasticsearch/aggregations/pipeline/MovFnPipelineAggregator.java","lineNumber":91,"sourceCode":"\n    @Override\n    public InternalAggregation reduce(InternalAggregation aggregation, AggregationReduceContext reduceContext) {\n        InternalMultiBucketAggregation<?, ?> histo = asMultiBucketAggregation(aggregation);\n        List<? extends InternalMultiBucketAggregation.InternalBucket> buckets = histo.getBuckets();\n        HistogramFactory factory = (HistogramFactory) histo;\n\n        List<MultiBucketsAggregation.Bucket> newBuckets = new ArrayList<>();\n\n        // Initialize the script\n        MovingFunctionScript.Factory scriptFactory = reduceContext.scriptService().compile(script, MovingFunctionScript.CONTEXT);\n        Map<String, Object> vars = new HashMap<>();\n        if (script.getParams() != null) {\n            vars.putAll(script.getParams());\n        }\n\n        MovingFunctionScript executableScript = scriptFactory.newInstance();\n        executableScript._setCancellationCheck(\n            () -> { if (reduceContext.isCanceled().get()) throw new TaskCancelledException(\"Cancelled\"); }\n        );\n\n        List<Double> values = buckets.stream()\n            .map(b -> resolveBucketValue(histo, b, bucketsPaths()[0], gapPolicy))\n            .filter(v -> v != null && v.isNaN() == false)\n            .toList();\n\n        int index = 0;\n        for (InternalMultiBucketAggregation.InternalBucket bucket : buckets) {\n            Double thisBucketValue = resolveBucketValue(histo, bucket, bucketsPaths()[0], gapPolicy);\n\n            // Default is to reuse existing bucket. Simplifies the rest of the logic,\n            // since we only change newBucket if we can add to it\n            MultiBucketsAggregation.Bucket newBucket = bucket;\n\n            if (thisBucketValue != null && thisBucketValue.isNaN() == false) {\n\n                // The custom context mandates that the script returns a double (not Double) so we","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/aggregations/src/main/java/org/elasticsearch/aggregations/pipeline/MovFnPipelineAggregator.java#L73-L109","documentation":"Error \"Cancelled\" thrown in elastic/elasticsearch.","triggerScenarios":"Thrown at modules/aggregations/src/main/java/org/elasticsearch/aggregations/pipeline/MovFnPipelineAggregator.java:91 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}