Skip to content

Remove @UpdateForV9 annotation from ReindexRequest#failOnSizeSpecified #122729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Contributor Author

@arteam arteam Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't check the compatibility mode for the parameter rejected by the parser, so the compatibility test

./gradlew ":modules:reindex:yamlRestCompatTest" --tests "org.elasticsearch.index.reindex.ReindexClientYamlTestSuiteIT.test {yaml=reindex/20_validation/specifying size fails}"

fails if we don't mute it.

}
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/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we instead keep the test but generalize this regex to handle both the old specialized message and the new general one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've updated it!

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");
}
}