Legacy singbox protobuf gencode prevents further loading

未關閉
#9 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
42/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
docker, python
領域
backend, devops

研究方向

在使用 protobuf-5.28.3 且不含 C 描述子的 python:3.13.2-alpine3.21 容器中重現匯入失敗。從 traceback 中的 xtlsapi/init.py、singbox_api/stats_pb2.py 與 singbox_api/extensions_pb2.py 開始。當 XrayClient 在該環境中能夠成功匯入,且 singbox API 仍然可用時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

bug help wanted

Describe the bug
Hi team hiddify,
It's an awesome xtlsapi you created. It works well on windows, but there were issues when I tried to deploy it on docker. I encountered the following problem in python:alpine container, causing the container to fail to start:

>>> from xtlsapi import XrayClient
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    from xtlsapi import XrayClient
  File "/usr/local/lib/python3.13/site-packages/xtlsapi/__init__.py", line 2, in <module>
    from xtlsapi.client.SingboxClient import SingboxClient
  File "/usr/local/lib/python3.13/site-packages/xtlsapi/client/SingboxClient.py", line 3, in <module>
    from xtlsapi.singbox_api_services import APIService
  File "/usr/local/lib/python3.13/site-packages/xtlsapi/singbox_api_services/__init__.py", line 1, in <module>
    from .stats import StatsAPIService
  File "/usr/local/lib/python3.13/site-packages/xtlsapi/singbox_api_services/stats/__init__.py", line 1, in <module>
    from .get_client_upload_traffic import GetClientUploadTraffic
  File "/usr/local/lib/python3.13/site-packages/xtlsapi/singbox_api_services/stats/get_client_upload_traffic.py", line 2, in <module>
    from xtlsapi.singbox_api import stats_pb2
  File "/usr/local/lib/python3.13/site-packages/xtlsapi/singbox_api/stats_pb2.py", line 14, in <module>
    from . import extensions_pb2 as extensions__pb2
  File "/usr/local/lib/python3.13/site-packages/xtlsapi/singbox_api/extensions_pb2.py", line 22, in <module>
    google_dot_protobuf_dot_descriptor__pb2.MessageOptions.RegisterExtension(message_opt)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'MessageOptions' has no attribute 'RegisterExtension'

This seems to be related to https://github.com/mlflow/mlflow/issues/11811. Legacy singbox protobuf gencode prevents further loading when using protobuf without C descriptors, even if not singbox module is imported.

To Reproduce
It's easy to reproduce:

docker run -it python:alpine /bin/sh
pip install xtlsapi
from xtlsapi import XrayClient

Expected behavior
Upgrade singbox protobuf gencode, or lazy import singbox part.

Desktop (please complete the following information):

  • docker image python:3.13.2-alpine3.21
  • OS: Alpine Linux 3.21
  • Python 3.13.2
  • using protobuf without C descriptors, like protobuf-5.28.3-py3-none-any.whl
主要語言
Python
星號
64
分支
20
PR 合併指標
30 天內沒有已合併 PR

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

hiddify/xtlsapi 的其他 Issue

查看 hiddify/xtlsapi 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。