-
Notifications
You must be signed in to change notification settings - Fork 25.8k
XContentParser with excludes filters emits invalid json in common cases #80142
Copy link
Copy link
Open
Labels
:Core/Infra/CoreCore issues without another labelCore issues without another label>bugTeam:Core/InfraMeta label for core/infra teamMeta label for core/infra team
Description
Elasticsearch version (bin/elasticsearch --version): master
Plugins installed: [] no
JVM version (java -version):
OS version (uname -a if on a Unix-like system):
Description of the problem including expected versus actual behavior:
Steps to reproduce:
Please include a minimal but complete recreation of the problem,
including (e.g.) index creation, mappings, settings, query etc. The easier
you make for us to reproduce it, the more likely that somebody will take the
time to look at it.
- add a test in
AbstractXContentFilteringTestCase
public void testExcludesFailed() throws IOException {
final Builder sample = builder -> builder.startObject().field("bar", "test1").field("foo", "test2").endObject();
Builder expected = builder -> builder.startObject().field("bar", "test1").field("foo", "test2").endObject();
testFilter(expected, sample, emptySet(), singleton("bar.xxx"));
}
- throw the exception:
com.fasterxml.jackson.core.JsonGenerationException: Can not write a field name, expecting a value
at __randomizedtesting.SeedInfo.seed([D5C7EEE02AA53137:388E1895E77A618D]:0)
at com.fasterxml.jackson.core.JsonGenerator._reportError(JsonGenerator.java:2080)
at com.fasterxml.jackson.core.json.UTF8JsonGenerator.writeFieldName(UTF8JsonGenerator.java:220)
at com.fasterxml.jackson.core.JsonGenerator._copyCurrentContents(JsonGenerator.java:1938)
at com.fasterxml.jackson.core.JsonGenerator.copyCurrentStructure(JsonGenerator.java:1914)
at org.elasticsearch.xcontent.json.JsonXContentGenerator.copyCurrentStructure(JsonXContentGenerator.java:396)
at org.elasticsearch.xcontent.XContentBuilder.copyCurrentStructure(XContentBuilder.java:1161)
at org.elasticsearch.xcontent.support.filtering.AbstractXContentFilteringTestCase.filterOnParser(AbstractXContentFilteringTestCase.java:87)
at org.elasticsearch.xcontent.support.filtering.AbstractXContentFilteringTestCase.testExcludesFailed(AbstractXContentFilteringTestCase.java:94)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at com.carrotsearch.randomizedtesting.RandomizedRunner.invoke(RandomizedRunner.java:1758)
at com.carrotsearch.randomizedtesting.RandomizedRunner$8.evaluate(RandomizedRunner.java:946)
at com.carrotsearch.randomizedtesting.RandomizedRunner$9.evaluate(RandomizedRunner.java:982)
I think the right action is passed the test.
It appears in excludes mode.
when excludes pattern contain than longer than input. like:
{
"bar" : "test1",
"foo" : "test2"
}
and the pattern is : bar.xxx.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
:Core/Infra/CoreCore issues without another labelCore issues without another label>bugTeam:Core/InfraMeta label for core/infra teamMeta label for core/infra team
Type
Fields
Give feedbackNo fields configured for issues without a type.