Skip to content
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

Improve error message for parse failures of completion fields #27297

Conversation

DaveCTurner
Copy link
Contributor

Fix spacing/grammar/punctuation, and include the field name and location in the source document.

@DaveCTurner DaveCTurner added :Search Relevance/Suggesters "Did you mean" and suggestions as you type v6.1.0 v7.0.0 labels Nov 7, 2017
@@ -560,7 +560,7 @@ private void parse(ParseContext parseContext, Token token, XContentParser parser
}
}
} else {
throw new ElasticsearchParseException("failed to parse expected text or object got" + token.name());
throw new ElasticsearchParseException("failed to parse [" + parser.currentName() + "][" + parser.getTokenLocation() + "]: expected text or object, but got " + token.name());
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it would make sense to use ParsingException otherwise, which supports token location natively.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, that's nicer than putting it in the string. Thanks.

DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1", new CompressedXContent(mapping));

try {
defaultMapper.parse(SourceToParse.source("test", "type1", "1", XContentFactory.jsonBuilder()
Copy link
Member

Choose a reason for hiding this comment

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

you could use expectThrows here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah thanks, I was just about to ask for a better way to do this :)

@DaveCTurner DaveCTurner removed the request for review from ywelsch November 7, 2017 10:25
@DaveCTurner DaveCTurner assigned javanna and unassigned javanna Nov 7, 2017
@DaveCTurner DaveCTurner requested a review from javanna November 7, 2017 10:25
Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

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

LGTM thanks @DaveCTurner

@DaveCTurner
Copy link
Contributor Author

Failure looks unrelated. @elasticmachine please test this again.

1 similar comment
@DaveCTurner
Copy link
Contributor Author

Failure looks unrelated. @elasticmachine please test this again.

@DaveCTurner DaveCTurner merged commit 1c6f5ce into elastic:master Nov 9, 2017
DaveCTurner added a commit that referenced this pull request Nov 9, 2017
Fix spacing/grammar/punctuation, and include the field name and location in the source document.
@DaveCTurner
Copy link
Contributor Author

Merged to master as 1c6f5ce and 6.x as 9d468af.

@DaveCTurner DaveCTurner deleted the 2017-11-07-completion-parse-error-message branch November 9, 2017 10:48
jasontedor added a commit that referenced this pull request Nov 9, 2017
* master: (22 commits)
  Update Tika version to 1.15
  Aggregations: bucket_sort pipeline aggregation (#27152)
  Introduce templating support to timezone/locale in DateProcessor (#27089)
  Increase logging on qa:mixed-cluster tests
  Update to AWS SDK 1.11.223 (#27278)
  Improve error message for parse failures of completion fields (#27297)
  Ensure external refreshes will also refresh internal searcher to minimize segment creation (#27253)
  Remove optimisations to reuse objects when applying a new `ClusterState` (#27317)
  Decouple `ChannelFactory` from Tcp classes (#27286)
  Fix find remote when building BWC
  Remove colons from task and configuration names
  Add unreleased 5.6.5 version number
  testCreateSplitIndexToN: do not set `routing_partition_size` to >= `number_of_routing_shards`
  Snapshot/Restore: better handle incorrect chunk_size settings in FS repo (#26844)
  Add limits for ngram and shingle settings (#27211) (#27318)
  Correct comment in index shard test
  Roll translog generation on primary promotion
  ObjectParser: Replace IllegalStateException with ParsingException (#27302)
  scripted_metric _agg parameter disappears if params are provided (#27159)
  Update discovery-ec2.asciidoc
  ...
jasontedor added a commit that referenced this pull request Nov 9, 2017
* 6.x:
  Update Tika version to 1.15
  Introduce templating support to timezone/locale in DateProcessor (#27089)
  Increase logging on qa:mixed-cluster tests
  Update to AWS SDK 1.11.223 (#27278)
  Improve error message for parse failures of completion fields (#27297)
  Remove optimisations to reuse objects when applying a new `ClusterState` (#27317)
  Decouple `ChannelFactory` from Tcp classes (#27286)
  Use PlainListenableActionFuture for CloseFuture (#26242)
  Fix find remote when building BWC
  Remove colons from task and configuration names
  Fix snapshot getting stuck in INIT state (#27214)
  Snapshot/Restore: better handle incorrect chunk_size settings in FS repo (#26844)
  Add unreleased 5.6.5 version number
  testCreateSplitIndexToN: do not set `routing_partition_size` to >= `number_of_routing_shards`
  Correct comment in index shard test
  Roll translog generation on primary promotion
  ObjectParser: Replace IllegalStateException with ParsingException (#27302)
  scripted_metric _agg parameter disappears if params are provided (#27159)
  Update discovery-ec2.asciidoc
@DaveCTurner DaveCTurner restored the 2017-11-07-completion-parse-error-message branch November 22, 2017 15:43
@DaveCTurner DaveCTurner deleted the 2017-11-07-completion-parse-error-message branch July 23, 2022 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants