opensearch-py
opensearch-py copied to clipboard
[BUG] .refresh() returns 404 on existing index (on Serverless)
What is the bug?
If I call .exists()
to confirm that a given index exists:
>>> client.indices.exists("locations-1234")
True
Then it doesn't make sense that calling .refresh()
on the same index should return 404:
>>> client.indices.refresh("locations-1234")
[stack trace skipped]
opensearchpy.exceptions.NotFoundError: NotFoundError(404, '')
It may be failing for some other reason, but it shouldn't be 404 since we know it exists.
Note this happens only in an AWS Serverless OpenSearch environment. The bug does not occur on localhost with brew-installed OpenSearch.
I see .refresh() that is documented as unsupported, but the library should be able to detect the environment and return a better response.
How can one reproduce the bug?
As above
What is the expected behavior?
A useful error message and different return value is returned.
What is your host/environment?
AWS Serverless
Do you have any screenshots?
Do you have any additional context?
N/A
Hello @shacker, I will take a look. And also If you're interested in contributing, feel free to take it up. Thank you :)
I believe this is just not supported by serverless.
https://repost.aws/questions/QUSYfaKYMzTn2dUPr-oW9maA/aws-opensearch-serverless-supports-for-refresh-wait-for-and-refresh-true
@dblock Correct - I mentioned that in my bug report. I'm saying that 404 is an incorrect response for an unsupported feature, that's all. Cheers.
Hm, what do you think it should raise? I think the service deliberately chose 404s for things that don't exist.
@dblock 404 is for a resource (record or file) that doesn't exist, like a non-existent index name. I think calling a method that's unsupported should be 405, "Method not allowed."
I decided to close this, no hard feelings. This isn't a problem with the client which just returns what the server returns.
I don't disagree that 405 may be a better code btw, but I doubt that Amazon Serverless would change the 404 to a 405.