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

Suggest REST endpoint fix for POST/PUT #5443

Closed
wants to merge 1 commit into from
Closed

Suggest REST endpoint fix for POST/PUT #5443

wants to merge 1 commit into from

Conversation

aleph-zero
Copy link
Contributor

Fix an odd behavior whereby a user can create documents with id=_suggest
by issuing POST/PUT requests to
http://localhost:9200/{index}/{type}/_suggest.

This fix intercepts such requests and returns a 400 BAD_REQUEST
response.

Additionally, this commit includes an extension to the standard
integration test facilities which allows a subclass to use a RestClient
instance to issue REST requests.

Closes #5442

Fix an odd behavior whereby a user can create documents with id=_suggest
by issuing POST/PUT requests to
http://localhost:9200/{index}/{type}/_suggest.

This fix intercepts such requests and returns a 400 BAD_REQUEST
response.

Additionally, this commit includes an extension to the standard
integration test facilities which allows a subclass to use a RestClient
instance to issue REST requests.

Closes #5442
@javanna
Copy link
Member

javanna commented Mar 17, 2014

I'm on the fence on this change... isn't the result the same as preventing a document to be indexed if it has _suggest as id? Couldn't we handle this in the index api then instead of adding support for PUT here to be able to throw an error?

Also, I'd much rather prefer to keep testing the REST layer using yaml tests, which are shared between all the clients as well. Handling this in the index api would make it easier to test it as well.

Maybe we'd need to consider validating the document ids and prevent users from using any of our own registered _endpoints just to avoid confusion?

@s1monw
Copy link
Contributor

s1monw commented Mar 17, 2014

+1 to validiate doc IDs based on the endpoints we have so it's actually dynamic!

@clintongormley
Copy link

Just because an ID doesn't clash with an existing endpoint doesn't mean that it won't clash in the future. I think we should say that IDs can't begin with an underscore.

Closing in favour of #6736

@aleph-zero aleph-zero deleted the issue-5442 branch October 21, 2014 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REST API _suggest endpoint mistakenly creates documents with id = _suggest
4 participants