Better error message when an inference model cannot be parsed due to its size #59166
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When parsing model definitions there is sensibly a limit on how large the stream size can be. On such an error the actual reason will be at the end of long chain of
XContentParseException
s{'error': {'root_cause': [{'type': 'x_content_parse_exception', 'reason': '[1:107374158] [tree_inference_model_node] failed to parse object'}], 'type': 'x_content_parse_exception', 'reason': '[1:107374158] [inference_model_definition] failed to parse field [trained_model]', 'caused_by': {'type': 'x_content_parse_exception', 'reason': '[1:107374158] [trained_model] failed to parse field [ensemble]', 'caused_by': {'type': 'x_content_parse_exception', 'reason': '[1:107374158] [ensemble_inference_model] failed to parse field [trained_models]', 'caused_by': {'type': 'x_content_parse_exception', 'reason': '[1:107374158] [trained_models] failed to parse field [tree]', 'caused_by': {'type': 'x_content_parse_exception', 'reason': '[1:107374158] [tree_inference_model] failed to parse field [tree_structure]', 'caused_by': {'type': 'x_content_parse_exception', 'reason': '[1:107374158] [tree_inference_model_node] failed to parse object', 'caused_by': {'type': 'i_o_exception', 'reason': 'input stream exceeded maximum bytes of [107374182]'}}}}}}}}
Where
'reason': 'input stream exceeded maximum bytes of [107374182]
is the interesting part.This change brings that reason to the top and provides a more helpful message
"Cannot parse model definition as the content is larger than the maximum stream size of [X] bytes. Max stream size is 10% of the JVM heap or 1GB whichever is smallest"