Skip to content

feat(audits/server): Server response in failing audits #39

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

Merged
merged 13 commits into from
Jan 19, 2023

Conversation

enisdenjo
Copy link
Member

Closes #10

@enisdenjo enisdenjo merged commit 4385ecb into main Jan 19, 2023
@enisdenjo enisdenjo deleted the response-in-audit branch January 19, 2023 11:23
enisdenjo pushed a commit that referenced this pull request Jan 20, 2023
# [1.12.0](v1.11.0...v1.12.0) (2023-01-20)

### Bug Fixes

* **audits/server:** Check the actual content encoding instead of the indication ([#41](#41)) ([67778a8](67778a8))
* **handler:** Response maker handles errors correctly ([#45](#45)) ([5a10e0b](5a10e0b))

### Features

* **audits/server:** Server response in failing audits ([#39](#39)) ([4385ecb](4385ecb))
@enisdenjo
Copy link
Member Author

🎉 This PR is included in version 1.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@enisdenjo enisdenjo added the released Has been released and published label Jan 20, 2023
Comment on lines +80 to +82
if (res.status !== code) {
throw new AuditError(res, `Response status code is not ${code}`);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We filter some of the SHOULD results from this test suite based on the text of the reason, so this broke our usage here:
https://github.com/apollographql/apollo-server/blob/37b3b7fb57ea105f40776166c9532536fd3f053d/packages/integration-testsuite/src/httpSpecTests.ts#L65

@enisdenjo This change also dropped the actual error code that was seen in the message (i.e. previously we expected a 400 in this string), it might be nice to restore res.status to the string here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any expectation that the reason is stable (is this a breaking change that should be fixed in a patch?) or should we assume these might change and be prepared to update our filtering logic?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for reporting! Sorry if this was a breaking change, those were not my intentions.

This change also dropped the actual error code that was seen in the message (i.e. previously we expected a 400 in this string), it might be nice to restore res.status to the string here?

Failing audits now have the complete response in the AuditFail.response object. Can this be helpful in your case?

Is there any expectation that the reason is stable (is this a breaking change that should be fixed in a patch?) or should we assume these might change and be prepared to update our filtering logic?

The reason itself is not subject to versioning, hence not a breaking change. However, I understand you use case - do you have any suggestions on identifying tests without depending on the reason? Maybe give each test an ID uniquely representing the case?

Copy link
Contributor

@trevor-scheer trevor-scheer Jan 23, 2023

Choose a reason for hiding this comment

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

@enisdenjo That's actually a great mitigation, thanks for the suggestion!
apollographql/apollo-server@31736b5

If the name is also not expected to be stable then a unique ID would be great. I would really like to be more explicit about which warnings we're allowing in our implementation. IDs would let me just do allowedWarningIDs.includes(audit.id) or something to that effect.

I suppose we could be doing this now with the names as I've alluded to, but maybe that's better as a human-readable description of the test which might be tweaked / improved upon in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

@trevor-scheer I'd love to hear your thoughts on #49, would that be a fitting enhancement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Has been released and published
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Increase the verbosity of failing audits
2 participants