-
Notifications
You must be signed in to change notification settings - Fork 75
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
test(core): Update network_reader_with_valid_http_header_kv_pairs
to verify the return value before parsing the read content into a JSON object.
#593
Conversation
WalkthroughThe changes in this pull request involve modifications to the Changes
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
components/core/tests/test-NetworkReader.cpp (2)
216-216
: Consider a more descriptive variable nameThe variable name change from
content
tocontext
might be confusing as the variable actually contains the HTTP response content, not a context.- auto const context{get_content(reader)}; + auto const response_content{get_content(reader)};
216-219
: Consider adding platform-specific error handlingSince the PR objectives mention failures in macOS workflow runs, consider adding platform-specific error handling similar to what's done in the
network_reader_illegal_offset
test case.auto const context{get_content(reader)}; - REQUIRE(assert_curl_error_code(CURLE_OK, reader)); + if constexpr (clp::Platform::MacOs == clp::cCurrentPlatform) { + // Handle potential 502 errors differently on macOS + if (!assert_curl_error_code(CURLE_OK, reader)) { + auto const ret_code = reader.get_curl_ret_code(); + if (ret_code.has_value() && ret_code.value() == CURLE_GOT_NOTHING) { + FAIL(fmt::format( + "MacOS-specific HTTP error: {}", + reader.get_curl_error_msg().value_or("502 Bad Gateway") + )); + } + } + } else { + REQUIRE(assert_curl_error_code(CURLE_OK, reader)); + }
…o verify the return value before parsing the read content into a JSON object. (y-scope#593)
Description
We've seen
network_reader_with_valid_http_header_kv_pairs
test failures in recent macOS workflow runs. These runs can be normally resolved by rerunning the workflow jobs. After further investigation, we realized the requested URL returned an error code 502. This is not our fault; however, the current unit test won't give us a straightforward error message. This PR improves error reporting by reordering the test code to check CURL return code before parsing the read content into a JSON object.The error message before this PR on failure:
The error message after this PR:
After the fix, the error message should look more apparent, as if the error is not on our end.
Validation performed
Summary by CodeRabbit
network_reader_with_valid_http_header_kv_pairs
test case by renaming variables for better understanding.