-
Notifications
You must be signed in to change notification settings - Fork 66
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
Catch response deserialization errors. #478
Conversation
Changes AnalysisCommit SHA: 8b6352f API ChangesSummaryNO CHANGES ReportThe full API changes report is available at: https://github.com/opensearch-project/opensearch-api-specification/actions/runs/10323054944/artifacts/1795938041 API Coverage
|
Spec Test Coverage Analysis
|
Signed-off-by: dblock <dblock@amazon.com>
Signed-off-by: dblock <dblock@amazon.com>
3d93780
to
3b178c1
Compare
bc9c062
to
7911c58
Compare
@@ -16,7 +16,6 @@ prologues: | |||
overall: | |||
result: ERROR | |||
message: no such index [does_not_exists] | |||
error: Request failed with status code 404 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These aren't actually errors per-se, they get parsed and properly reflected in the failures of the test.
@@ -122,15 +122,17 @@ export default class ChapterEvaluator { | |||
|
|||
#evaluate_status(chapter: Chapter, response: ActualResponse): Evaluation { | |||
const expected_status = chapter.response?.status ?? 200 | |||
if (response.status === expected_status) return { result: Result.PASSED } | |||
if (response.status === expected_status && response.error === undefined) return { result: Result.PASSED } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is checking response.error === undefined
necessary? From the surface when reading this line, I interpret the business logic as: Even if the status is 403 as the test story expects, the test will still fail regardless because it's an error.
Meanwhile the implementation here says other wise. It guarantees that only either response.status
or response.error
is set, but not both. That means if response.status === expected_status (which is not null)
then response.error === undefined
is also true.
It a small thing to nit-pick but keeping the guards simple and close to the high-level logic makes it a lot easier to maintain :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the server responded with the expected status (200), but data failed to deserialize, an exception will be thrown and you will end up with a matching status, but no response.error
.
Without:
FAILED Cat in different formats (format=smile).
PASSED PARAMETERS
PASSED format
PASSED REQUEST BODY
PASSED RESPONSE STATUS
FAILED RESPONSE PAYLOAD BODY (missing $root='[object Object]')
FAILED RESPONSE PAYLOAD SCHEMA (data must be array)
SKIPPED RESPONSE OUTPUT VALUES
With:
ERROR Cat in different formats (format=cbor).
PASSED PARAMETERS
PASSED format
PASSED REQUEST BODY
ERROR RESPONSE STATUS (Received 200: application/cbor. Additional info not implemented: 29)
SKIPPED RESPONSE PAYLOAD BODY
SKIPPED RESPONSE PAYLOAD SCHEMA
SKIPPED RESPONSE OUTPUT VALUES
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this snippet, response.status
and response.error
are assigned in different code paths (i.e. mutual exclusive), how do you get them both at the same time?
It's a just a small nitpick tho. If it does happens like you describe then it's all good :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that catch
re-throwing into itself?! it totally happens
Signed-off-by: dblock <dblock@amazon.com>
7911c58
to
8b6352f
Compare
Description
After doing #476 I ran tests against AOS 2.7 and ran into an error deserializing CBOR. The implementation here will catch deserialization errors and bubble them up instead of failing unexpectedly.
Before:
After:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.