Skip to content

Protobuf 4.x compatibility still broken in v0.13.8 - ImportError: cannot import name '_message' #680

@idobiran11

Description

@idobiran11

Description

Problem:
Despite the attempted fix in commit 0ab4b63, v3io-frames 0.13.8 still fails to work with protobuf 4.x+ versions due to an unresolved _message import
error.

Error:
ImportError: cannot import name '_message' from 'google.protobuf.pyext'
(/path/to/site-packages/google/protobuf/pyext/init.py)

Complete Stack Trace:
File "v3io_frames/init.py", line 26, in
from .grpc import Client as gRPCClient
File "v3io_frames/grpc.py", line 31, in
from .http import format_go_time
File "v3io_frames/http.py", line 32, in
from .pbutils import df2msg, msg2df, pb2py
File "v3io_frames/pbutils.py", line 18, in
from google.protobuf.pyext import cpp_message
File "google/protobuf/pyext/cpp_message.py", line 23, in
from google.protobuf.pyext import _message
ImportError: cannot import name '_message' from 'google.protobuf.pyext'

Environment

  • v3io-frames version: 0.13.8 (July 2024)
  • protobuf version: 4.25.8 (should be supported)
  • Python version: 3.11.13
  • MLRun version: 1.9.2 (affected downstream package)

Expected Behavior

v3io-frames should work seamlessly with modern protobuf versions (4.x, 5.x, 6.x) as the library doesn't specify version constraints, indicating intended compatibility.

Impact

This compatibility issue:

  • Blocks the entire MLRun ecosystem from using modern protobuf versions
  • Forces users to implement monkey-patch workarounds instead of having proper compatibility
  • Prevents adoption of modern Python packages that require protobuf 4.x+
  • Creates dependency conflicts in production environments

Root Cause

The protobuf 4.x C++ API changes removed google.protobuf.pyext._message in the same way it was previously available. The fix in commit 0ab4b63 appears to have been incomplete or doesn't cover all code paths.

Reproduction

  1. Install v3io-frames 0.13.8 with protobuf 4.25.8+
  2. Try to import: from v3io_frames import Client
  3. Error occurs immediately during import

Current Workaround

Users are forced to implement this monkey patch:
import sys
from unittest.mock import MagicMock
import google.protobuf.pyext

if not hasattr(google.protobuf.pyext, '_message'):
google.protobuf.pyext._message = MagicMock()

if 'google.protobuf.pyext.cpp_message' not in sys.modules:
sys.modules['google.protobuf.pyext.cpp_message'] = MagicMock()

Request

Please:

  1. Complete the protobuf 4.x+ compatibility fix - the current implementation still has compatibility issues
  2. Add automated testing for protobuf versions 4.x through 6.x to prevent regressions
  3. Test with Python 3.9-3.13 to ensure broad compatibility
  4. Consider using pure Python protobuf implementation as a fallback for better compatibility

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions