MinIO: InvalidCredsError when trying to retrieve an object

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

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

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

研究方向

從 tests/test_demo_bug.py 開始,使用 pytest -k test_demo_InvalidCreds 重現該失敗。追蹤 MinIO get_object 在 s3.py 中的呼叫流程,尤其關注 S3Response.parse_error 和 HEAD 請求,然後新增回歸測試涵蓋,證明取得已上傳的物件不會引發 InvalidCredsError,同時真正的憑證失敗仍可被識別。

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

描述

api: storage drivers: minio stale

Summary

When using the minio provider and getting an object, the method raises an libcloud.common.types.InvalidCredsError, despite the fact that it was able to create a container and upload it the object (so it doesn't look like a credential issue)
100% repro, code to repro the bug is provided

Detailed Information

libcloud: latest stable, 3.3.1
Python: 3.8.10
OS: Ubuntu 20.04

Here you can find a repo to repro the bug, using pytest (Actually there are 2 bugs to report):
https://github.com/Wenzel/libcloud_bug

$ pytest -k test_demo_InvalidCreds
__________________________________________________________________________________________ test_demo_InvalidCreds ___________________________________________________________________________________________

clean_minio_db = <libcloud.storage.drivers.minio.MinIOStorageDriver object at 0x7f76b6282a00>, tmp_path = PosixPath('/tmp/pytest-of-wenzel/pytest-22/test_demo_InvalidCreds0')

    def test_demo_InvalidCreds(clean_minio_db, tmp_path):
        # setup
        expected_data = b"data"
        with open(tmp_path / "file1.txt", "wb") as f:
            f.write(expected_data)
        adapter = clean_minio_db
        c = adapter.create_container("objects")
        # test
        ret = adapter.upload_object(tmp_path / "file1.txt", c, "file1")
>       obj = adapter.get_object(c, "file1")

tests/test_demo_bug.py:31: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../.cache/pypoetry/virtualenvs/libcloud-bug-IT-EyGKG-py3.8/lib/python3.8/site-packages/libcloud/storage/drivers/s3.py:370: in get_object
    response = self.connection.request(object_path, method='HEAD')
../../.cache/pypoetry/virtualenvs/libcloud-bug-IT-EyGKG-py3.8/lib/python3.8/site-packages/libcloud/common/base.py:655: in request
    response = responseCls(**kwargs)
../../.cache/pypoetry/virtualenvs/libcloud-bug-IT-EyGKG-py3.8/lib/python3.8/site-packages/libcloud/common/base.py:166: in __init__
    message=self.parse_error(),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <libcloud.storage.drivers.s3.S3Response object at 0x7f76b6282700>

    def parse_error(self):
        if self.status in [httplib.UNAUTHORIZED, httplib.FORBIDDEN]:
>           raise InvalidCredsError(self.body)
E           libcloud.common.types.InvalidCredsError: ''

../../.cache/pypoetry/virtualenvs/libcloud-bug-IT-EyGKG-py3.8/lib/python3.8/site-packages/libcloud/storage/drivers/s3.py:138: InvalidCredsError
------------------------------------------------------------------------------------------- Captured stdout setup -------------------------------------------------------------------------------------------
ca19a7e29a92d875ec58b0285c854403ae5a95433a71e084011d32018a9141d1
----------------------------------------------------------------------------------------- Captured stdout teardown ------------------------------------------------------------------------------------------
libcloud_bug_objectmistmatch_miniodb
========================================================================================== short test summary info ==========================================================================================
FAILED tests/test_demo_bug.py::test_demo_InvalidCreds - libcloud.common.types.InvalidCredsError: ''

Thanks for your help !

主要語言
Python
星號
2.1k
分支
935
平均合併
5 天 3 小時
30 天內合併 PR
15

環境準備

從這裡開始

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

apache/libcloud 的其他 Issue

查看 apache/libcloud 的全部 Issue

相似的 Issue

更多 Python Issue

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

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