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

feat: coerces missing "body" of the actual HTTP message #199

Merged
merged 2 commits into from Jun 20, 2019

Conversation

artem-zakharchenko
Copy link
Contributor

// 1. Expcected '', and got '' (TextDiff/TextDiff, valid)
// 2. Expected {...}, but got '' (Json/TextDiff, invalid, produces "missing real body" error)
// 3. Expected {...}, but git "foo" (Json/TextDiff, invalid, produces types mismatch error).
if (expected.body !== '' && hasEmptyRealBody) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't the best solution in terms of cyclomatic complexity, but the one that works without introducing an entirely custom flow for missing body. This way we can always coerce missing actual "body" to an empty string and properly differentiate between three mentioned scenarios.

Copy link
Contributor

@honzajavorek honzajavorek left a comment

Choose a reason for hiding this comment

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

👍

lib/units/validateBody.js Outdated Show resolved Hide resolved
lib/units/validateBody.js Outdated Show resolved Hide resolved
@artem-zakharchenko artem-zakharchenko merged commit 89e7d08 into master Jun 20, 2019
@artem-zakharchenko artem-zakharchenko deleted the 198-coerce-missing-real-body branch June 20, 2019 11:58
@ApiaryBot
Copy link
Collaborator

🎉 This PR is included in version 6.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Provide missing real body coercion
3 participants