Skip to content

Commit

Permalink
Restore check in RestCompatibleVersionHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-ivanov-es committed Dec 12, 2024
1 parent f458502 commit a7b77d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.core.UpdateForV9;
import org.elasticsearch.xcontent.MediaType;
import org.elasticsearch.xcontent.ParsedMediaType;

Expand All @@ -27,7 +26,6 @@ class RestCompatibleVersionHelper {
/**
* @return The requested API version, or {@link Optional#empty()} if there was no explicit version in the request.
*/
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)
static Optional<RestApiVersion> getCompatibleVersion(
@Nullable ParsedMediaType acceptHeader,
@Nullable ParsedMediaType contentTypeHeader,
Expand All @@ -52,8 +50,7 @@ static Optional<RestApiVersion> getCompatibleVersion(
if (hasContent) {

// content-type version must be current or prior
// This can be uncommented once all references to RestApiVersion.V_7 are removed
/*if (contentTypeVersion > RestApiVersion.current().major || contentTypeVersion < RestApiVersion.minimumSupported().major) {
if (contentTypeVersion > RestApiVersion.current().major || contentTypeVersion < RestApiVersion.minimumSupported().major) {
throw new ElasticsearchStatusException(
"Content-Type version must be either version {} or {}, but found {}. Content-Type={}",
RestStatus.BAD_REQUEST,
Expand All @@ -62,7 +59,7 @@ static Optional<RestApiVersion> getCompatibleVersion(
contentTypeVersion,
contentTypeHeader
);
}*/
}
// if both accept and content-type are sent, the version must match
if (contentTypeVersion != acceptVersion) {
throw new ElasticsearchStatusException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,14 @@ public void testObsoleteVersion() {
assertThat(
e.getMessage(),
equalTo(
"A compatible version is required on both Content-Type and Accept headers if either one has requested a "
+ "compatible version and the compatible versions must match. "
+ "Accept="
+ acceptHeader(PREVIOUS_VERSION)
+ ", Content-Type="
"Content-Type version must be either version "
+ CURRENT_VERSION
+ " or "
+ PREVIOUS_VERSION
+ ", but found "
+ OBSOLETE_VERSION
+ ". "
+ "Content-Type="
+ contentTypeHeader(OBSOLETE_VERSION)
)
);
Expand Down

0 comments on commit a7b77d1

Please sign in to comment.