Skip to content

Commit

Permalink
Remove @UpdateForV9 annotation from `ReindexRequest#failOnSizeSpeci…
Browse files Browse the repository at this point in the history
…fied` (#122729) (#122798)

The size parameter hasn't been accepted since 8.0, end users should use max_docs and if the user specify it, we can defer to the standard error message produced by the parser.
  • Loading branch information
arteam authored Feb 17, 2025
1 parent 7304580 commit 7ca37d3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
4 changes: 4 additions & 0 deletions modules/reindex/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,7 @@ if (OS.current() == OS.WINDOWS) {
}
}
}

tasks.named("yamlRestCompatTestTransform").configure { task ->
task.skipTest("reindex/20_validation/specifying size fails", "size is rejected in 9.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
body: { "text": "test" }

- do:
catch: /invalid parameter \[size\], use \[max_docs\] instead/
catch: /(invalid parameter \[size\], use \[max_docs\] instead|unknown field \[size\])/
reindex:
body:
source:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.core.UpdateForV9;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.query.QueryBuilder;
Expand Down Expand Up @@ -355,10 +354,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
);

PARSER.declareInt(ReindexRequest::setMaxDocsValidateIdentical, new ParseField("max_docs"));

// avoid silently accepting an ignored size.
PARSER.declareInt((r, s) -> failOnSizeSpecified(), new ParseField("size"));

PARSER.declareField((p, v, c) -> v.setScript(Script.parse(p)), new ParseField("script"), ObjectParser.ValueType.OBJECT);
PARSER.declareString(ReindexRequest::setConflicts, new ParseField("conflicts"));
}
Expand Down Expand Up @@ -498,10 +493,4 @@ static void setMaxDocsValidateIdentical(AbstractBulkByScrollRequest<?> request,
request.setMaxDocs(maxDocs);
}
}

@UpdateForV9(owner = UpdateForV9.Owner.DISTRIBUTED_INDEXING)
// do we still need this ref to [max_docs] or can we remove the field entirely so it's rejected with the default message?
private static void failOnSizeSpecified() {
throw new IllegalArgumentException("invalid parameter [size], use [max_docs] instead");
}
}

0 comments on commit 7ca37d3

Please sign in to comment.