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

Reject empty IDs #24118

Merged
merged 5 commits into from
Apr 15, 2017
Merged

Reject empty IDs #24118

merged 5 commits into from
Apr 15, 2017

Conversation

jasontedor
Copy link
Member

When indexing a document via the bulk API where IDs can be explicitly specified, we currently accept an empty ID. This is problematic because such a document can not be obtained via the get API. Instead, we should rejected these requets as accepting them could be a dangerous form of leniency. Additionally, we already have a way of specifying auto-generated IDs and that is to not explicitly specify an ID so we do not need a second way. This commit the individual requests where ID is specified but empty.

Closes #24116

When indexing a document via the bulk API where IDs can be explicitly
specified, we currently accept an empty ID. This is problematic because
such a document can not be obtained via the get API. Instead, we should
rejected these requets as accepting them could be a dangerous form of
leniency. Additionally, we already have a way of specifying
auto-generated IDs and that is to not explicitly specify an ID so we do
not need a second way. This commit the individual requests where ID is
specified but empty.
Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

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

LGTM, left one comment

@@ -499,6 +499,10 @@ public void process(@Nullable MappingMetaData mappingMd, String concreteIndex) {
}
}

if ("".equals(id)) {
Copy link
Member

@dakrone dakrone Apr 14, 2017

Choose a reason for hiding this comment

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

Out of curiousity, should we do Strings.hasText(id) == false here, to disallow the id " " also?

Copy link
Member Author

@jasontedor jasontedor Apr 14, 2017

Choose a reason for hiding this comment

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

I don't think we should reject " " (at least in this PR), it can be obtained via the get API (with escaping) and rejecting it would be a breaking change. On the indexing API we take care to return a properly-escaped location header.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me, I think it falls into the larger input validation category anyway

* master:
  Use sequence numbers to identify out of order delivery in replicas & recovery (elastic#24060)
  Remove customization of ES_USER and ES_GROUP
@jasontedor jasontedor merged commit 972bdc0 into elastic:master Apr 15, 2017
jasontedor added a commit that referenced this pull request Apr 15, 2017
When indexing a document via the bulk API where IDs can be explicitly
specified, we currently accept an empty ID. This is problematic because
such a document can not be obtained via the get API. Instead, we should
rejected these requets as accepting them could be a dangerous form of
leniency. Additionally, we already have a way of specifying
auto-generated IDs and that is to not explicitly specify an ID so we do
not need a second way. This commit rejects the individual requests where
ID is specified but empty.

Relates #24118
jasontedor added a commit that referenced this pull request Apr 15, 2017
When indexing a document via the bulk API where IDs can be explicitly
specified, we currently accept an empty ID. This is problematic because
such a document can not be obtained via the get API. Instead, we should
rejected these requets as accepting them could be a dangerous form of
leniency. Additionally, we already have a way of specifying
auto-generated IDs and that is to not explicitly specify an ID so we do
not need a second way. This commit rejects the individual requests where
ID is specified but empty.

Relates #24118
jasontedor added a commit that referenced this pull request Apr 15, 2017
When indexing a document via the bulk API where IDs can be explicitly
specified, we currently accept an empty ID. This is problematic because
such a document can not be obtained via the get API. Instead, we should
rejected these requets as accepting them could be a dangerous form of
leniency. Additionally, we already have a way of specifying
auto-generated IDs and that is to not explicitly specify an ID so we do
not need a second way. This commit rejects the individual requests where
ID is specified but empty.

Relates #24118
@jasontedor jasontedor deleted the reject-empty-id branch April 15, 2017 14:39
@jasontedor
Copy link
Member Author

Thanks @dakrone.

@lcawl lcawl added :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. and removed :Bulk labels Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. v5.3.1 v5.4.0 v5.5.0 v6.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants