Skip to content

Raise a CompilationError for unknown rules#445

Merged
timostamm merged 2 commits intomainfrom
tstamm/Raise-a-CompilationError-for-unknown-rules
Mar 23, 2026
Merged

Raise a CompilationError for unknown rules#445
timostamm merged 2 commits intomainfrom
tstamm/Raise-a-CompilationError-for-unknown-rules

Conversation

@timostamm
Copy link
Member

When a new field rule is added to validate.proto, implementations need to update to support it. If the implementation is not updated to support the rule, it may silently pass an invalid message with a new rule.

All other implementations of Protovalidate raise an error if they encounter an unknown rule. This PR adds the same functionality to protovalidate-python.

import celpy
from celpy import celtypes
from google.protobuf import any_pb2, descriptor, duration_pb2, message, message_factory, timestamp_pb2
from google.protobuf import any_pb2, descriptor, duration_pb2, message, message_factory, timestamp_pb2, unknown_fields # type: ignore[attr-defined]
Copy link
Member Author

Choose a reason for hiding this comment

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

From what I can see, this API (google.protobuf.unknown_fields) was added in 4.21.0.
There are no stubs in types-protobuf though.

Copy link
Member

Choose a reason for hiding this comment

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

@timostamm timostamm merged commit 0a10907 into main Mar 23, 2026
12 checks passed
@timostamm timostamm deleted the tstamm/Raise-a-CompilationError-for-unknown-rules branch March 23, 2026 16:18
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