Skip to content

Using deprecated Protobuf APIs #410

Closed

Description

@y4n9squared

I'm seeing many instances of

.venv/lib/python3.12/site-packages/protovalidate/internal/rules.py:863: DeprecationWarning: label() is deprecated. Use is_required() or is_repeated() instead.
    self._cache[descriptor] = self._new_rules(descriptor)

which stem from the fact that there are many accesses to FieldDescriptor.label which was deprecated in July 2025: https://protobuf.dev/news/2025-07-14/

These warnings start appearing when using the library with protobuf 6.x.

Activity

  1. stefanvanburen commented on Dec 18, 2025

    @stefanvanburen
    Contributor

    hey @y4n9squared — yeah, unfortunately that's expected; we support the protobuf runtime back to version 5, and I don't think those APIs are available to us until protobuf 6.x.

    I imagine there's maybe a runtime check we could do to see if we're on protobuf>6 and use the appropriate APIs; open to contributions!

  2. stefanvanburen commented on Dec 29, 2025

    @stefanvanburen
    Contributor

    I'm going to close this out in the sense that we don't plan on addressing these until dropping support for protobuf==5, which may be a while — still, if anyone wants to contribute the necessary runtime patching needed, I'm open to reviewing a PR!

  3. y4n9squared commented on Jan 6, 2026

    @y4n9squared
    Author

    I'm going to close this out in the sense that we don't plan on addressing these until dropping support for protobuf==5, which may be a while — still, if anyone wants to contribute the necessary runtime patching needed, I'm open to reviewing a PR!

    I am open to contributing a patch as it would move my project forward. When you say "runtime patching", do you mean to add a branch for

    sys.version_info >= (3, 14)

    and define a new set of functions that call the non-deprecated APIs?

  4. stefanvanburen commented on Jan 6, 2026

    @stefanvanburen
    Contributor

    @y4n9squared something like that, although I think the version check would be on the protobuf version in use — I think they introduced the new APIs / deprecated the old APIs somewhere in the runtime 6.x versions; we ought to use the new APIs when they're available based on the version check.

  5. y4n9squared commented on Jan 6, 2026

    @y4n9squared
    Author

    @y4n9squared something like that, although I think the version check would be on the protobuf version in use — I think they introduced the new APIs / deprecated the old APIs somewhere in the runtime 6.x versions; we ought to use the new APIs when they're available based on the version check.

    My bad. Yes, it will be on the proto library version.

  6. stefanvanburen commented on Jan 6, 2026

    @stefanvanburen
    Contributor

    @y4n9squared it shouldn't be too tricky to switch, but in case you needed a pointer, I attempted to switch to the newer APIs in #371. I imagine a helper function defined based on the runtime protobuf version to wrap those callsites would be a good approach.

  7. added a commit that references this issue on Feb 5, 2026
  8. mkanat commented on Mar 2, 2026

    @mkanat

    So, protobuf 7 actually removed .label, so now protovalidate is broken when using protobuf 7.

  9. added 2 commits that reference this issue on Mar 2, 2026
    95deafd
    415d038
  10. stefanvanburen commented on Mar 2, 2026

    @stefanvanburen
    Contributor

    hey @mkanat, thanks for the shout - opened #429 to get that fixed up.

  11. added a commit that references this issue on Mar 2, 2026
    f85bf45
  12. stefanvanburen commented on Mar 2, 2026

    @stefanvanburen
    Contributor

    Fix released in v1.1.2. Thanks for mentioning @mkanat, and thanks for the original report @y4n9squared!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions