Skip to content

Update to protovalidate 0.10.3 #73

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 14 commits into from
Mar 24, 2025

Conversation

smaye81
Copy link
Member

@smaye81 smaye81 commented Mar 21, 2025

This includes changes to the conformance tests and conformance runner in v0.10.2 and v0.10.3.

For now, we're skipping 165 failing test cases:

PASS (failed: 0, skipped: 165, passed: 2653, total: 2818)

NOTE: There are inconsistencies around some conformance tests (see expected_failures.yaml and search for FIXME). The current configuration in this PR passes CI with Bazel, but this will fail when running with CMake and running locally. There is an issue with how Bazel is reading these tests and it seems a bit of a waste to focus too much time since these tests are going to be fixed in the future anyway.

TL;DR - The failing unit tests are because conformance tests are failing via CMake. However, the same expected_failures file works for Bazel.

@smaye81 smaye81 requested a review from timostamm March 21, 2025 02:58
@smaye81 smaye81 marked this pull request as draft March 21, 2025 03:10
@smaye81
Copy link
Member Author

smaye81 commented Mar 21, 2025

Not ready for review yet. Some failing tests. In addition, the conformance runner sporadically segfaults with no discernible pattern. This happens locally and in CI.

When the conformance tests actually run, they all pass with the current expected failure list.

@@ -201,7 +201,8 @@ TEST(ValidatorTest, ValidateBadURIRefFailure) {
ASSERT_TRUE(violations_or.ok()) << violations_or.status();
EXPECT_EQ(violations_or.value().violations_size(), 1);
EXPECT_EQ(violations_or.value().violations(0).proto().constraint_id(), "string.uri_ref");
EXPECT_EQ(violations_or.value().violations(0).proto().message(), "value must be a valid URI");
EXPECT_EQ(
Copy link
Member Author

Choose a reason for hiding this comment

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

Verified my local clang-formatter is using the repo's clang-format rules.

@@ -201,7 +201,8 @@ TEST(ValidatorTest, ValidateBadURIRefFailure) {
ASSERT_TRUE(violations_or.ok()) << violations_or.status();
EXPECT_EQ(violations_or.value().violations_size(), 1);
EXPECT_EQ(violations_or.value().violations(0).proto().constraint_id(), "string.uri_ref");
EXPECT_EQ(violations_or.value().violations(0).proto().message(), "value must be a valid URI");
EXPECT_EQ(
violations_or.value().violations(0).proto().message(), "value must be a valid URI Reference");
Copy link
Member Author

Choose a reason for hiding this comment

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

This was the actual test fix. No idea how this was ever passing.

Comment on lines +437 to +441
// If hostSplit has a size greater than 1, then a '/' appeared in the string. Set the rest
// to remainder so we can parse any query string.
if (hostSplit.size() > 1) {
remainder = hostSplit[1];
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the segfault fix. The rest are just formatting changes.

@smaye81 smaye81 marked this pull request as ready for review March 21, 2025 18:26
@smaye81 smaye81 requested a review from jchadwick-buf March 21, 2025 18:26
@smaye81
Copy link
Member Author

smaye81 commented Mar 21, 2025

Update: it seems the difference may be related to Mac v. Linux envs. The current expected_failures is valid for all Ubuntu environments, while inverting the 5 tests marked as FIXME (i.e. uncomment those commented, comment out those uncommented) will pass on Mac but fail on Ubuntu. This is further confirmed by the fact that the conformance tests for Bazel only run in Ubuntu.

Will try to explore why that is, but in the meantime, I've disabled macos images for CMake conformance tests and everything passes.

Update 2: the difference appears to be related to the usage of arpa/inet.h and the calls to inet_pton for ipv6 addresses:

inet_pton(AF_INET6, str.data(), &result)

It seems to return inconsistent results on Mac vs. Linux when validating tests involving zone IDs. I did a bit of searching to see if this is documented anywhere, but couldn't find anything. But, again, unless there's an obvious/easy fix, these validation methods are going to be rewritten, so not worth a big effort to fix. Worth noting though that protovalidate-cc may currently validate differently on Linux vs. Mac in some cases for ipv6 addresses.

@smaye81
Copy link
Member Author

smaye81 commented Mar 24, 2025

Updated to use two different files for Mac v. Linux.

@jchadwick-buf
Copy link
Member

Thanks for debugging the issue. It feels obvious in retrospect, but I honestly was not getting very far when I looked myself.

@jchadwick-buf jchadwick-buf merged commit dfde683 into main Mar 24, 2025
7 checks passed
@jchadwick-buf jchadwick-buf deleted the sayers/update_protovalidate_0.10.3 branch March 24, 2025 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants