Skip to content

bug(bindings/python): Python bindings can throw different error types for the same error code #6235

@chitralverma

Description

@chitralverma

Describe the bug

write_with_if_not_exists capability is enabled on azblob service but it seems that when an object is written with if_not_exists option, the operation breaks

Ref: https://github.com/apache/opendal/actions/runs/15340065425/job/43164417657?pr=6086

Steps to Reproduce

@pytest.mark.need_capability("write", "delete", "write_with_if_not_exists")
def test_sync_writer_options(service_name, operator, async_operator):
    size = randint(1, 1024)
    filename = f"test_file_{str(uuid4())}.txt"
    content = os.urandom(size)
    f = operator.open(filename, "wb")
    written_bytes = f.write(content)
    assert written_bytes == size
    f.close()

    with pytest.raises(ConditionNotMatch):
        with operator.open(filename, "wb", if_not_exists=True) as w:
            w.write(content)

Expected Behavior

if the file exists error should be thrown as expected.

Additional Context

No response

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions