Skip to content

Conversation

@prdoyle
Copy link
Contributor

@prdoyle prdoyle commented Jul 21, 2025

CompressorFactory.compressor was over-eager in detecting XContent type even when the type was already known.

  1. Refactor out a non-detecting version of the CompressorFactory.compress method
  2. Add a failing unit test for NotXContentException on invalid xcontent should not cause 500 errors #131605
  3. Fix the bug

Fixes #131605.

@prdoyle prdoyle self-assigned this Jul 21, 2025
@prdoyle prdoyle added the :Core/Infra/Core Core issues without another label label Jul 21, 2025
@prdoyle prdoyle requested a review from a team as a code owner July 21, 2025 21:44
@prdoyle prdoyle added auto-backport Automatically create backport pull requests when merged v9.2.0 v8.19.1 >non-issue labels Jul 21, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Jul 21, 2025
@prdoyle
Copy link
Contributor Author

prdoyle commented Jul 21, 2025

@mosche - Is this something like what you had in mind?

Copy link
Contributor

@mosche mosche left a comment

Choose a reason for hiding this comment

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

Thanks @prdoyle, functionally this looks correct except for the missing assert in isCompressed . Looks like this even fixes some inconsistencies where uncompress might have thrown NotXContentException rather than NotCompressedException.
Though, I think we should try to not expose checkXContentType, adding a new deprecated method smells a bit. Can we keep that internal?

@prdoyle
Copy link
Contributor Author

prdoyle commented Jul 23, 2025

Ok @mosche I've force-pushed a less ambitious change, with three commits:

  1. Refactor out a non-detecting version of the CompressorFactory.compress method
  2. Add a failing unit test for NotXContentException on invalid xcontent should not cause 500 errors #131605
  3. Fix the bug

@prdoyle prdoyle requested a review from mosche July 23, 2025 18:04
throws IOException {
Objects.requireNonNull(xContentType);
Compressor compressor = CompressorFactory.compressorForUnknownXContentType(bytes);
Compressor compressor = CompressorFactory.compressor(bytes);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, the one call site I didn't change is the bug fix!

Copy link
Contributor

@mosche mosche left a comment

Choose a reason for hiding this comment

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

lgtm

@prdoyle prdoyle merged commit 75060a9 into elastic:main Jul 24, 2025
33 checks passed
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.19

prdoyle added a commit to prdoyle/elasticsearch that referenced this pull request Jul 24, 2025
* Refactor: split out non-detecting compressor method

* Unit test

* Fix createParser not to detect XContentType
prdoyle added a commit that referenced this pull request Jul 24, 2025
elasticsearchmachine pushed a commit that referenced this pull request Jul 24, 2025
This should have waited for approval from the breaking change committee.
I'll un-revert it when that approval arrives.

Reverts #131655
szybia added a commit to szybia/elasticsearch that referenced this pull request Jul 25, 2025
…king

* upstream/main: (90 commits)
  Register a blob cache long counter metric for total evicted regions (elastic#131862)
  Move plan attribute resolution to its own component (elastic#131830)
  Make restore support multi-project (elastic#131661)
  Use logically more correct expression (elastic#131869)
  [ES|QL] Change equals and hashcode for ConstantNullBlock (elastic#131817)
  Update `TransportVersion` to support a new model (elastic#131488)
  Correct slow log user for RCS 2.0 (elastic#130140)
  Revert "Remove 8.17 from dev branches"
  Mute org.elasticsearch.compute.aggregation.ValuesBytesRefGroupingAggregatorFunctionTests testSomeFiltered elastic#131878
  Remove 8.17 from dev branches
  Revert "CompressorFactory.compressor (elastic#131655)" (elastic#131866)
  Add fast path for single value in VALUES aggregator (elastic#130510)
  Resolve inference release tests failing due to missing feature flag  (elastic#131841)
  [Docs] Replace placeholder URLs (elastic#131309)
  CompressorFactory.compressor (elastic#131655)
  add availability info for speed loading setting (elastic#131714)
  [Logstash] Move `elastic_integration` plugin usage to ES logstash-bridge. (elastic#131486)
  Migrate x-pack-enrich legacy rest tests to new test framework (elastic#131743)
  Fix plugin example test failures due to deprecation warning (elastic#131819)
  Remove deprecated function isNotNullAndFoldable (elastic#130944)
  ...
prdoyle added a commit that referenced this pull request Aug 5, 2025
@prdoyle
Copy link
Contributor Author

prdoyle commented Aug 5, 2025

For the record... The backport didn't fail; I canceled it when I realized I needed to revert this in main.

prdoyle added a commit that referenced this pull request Aug 5, 2025
prdoyle added a commit to prdoyle/elasticsearch that referenced this pull request Aug 5, 2025
elasticsearchmachine pushed a commit that referenced this pull request Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged :Core/Infra/Core Core issues without another label >non-issue Team:Core/Infra Meta label for core/infra team v8.19.1 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NotXContentException on invalid xcontent should not cause 500 errors

3 participants