Skip to content

Why are FileObject commit errors handled silently? #543

@Mxbonn

Description

@Mxbonn

When using FileObjects:

file = FileObject(
    backend="s3_nonexistent",
    filename="test.png",
    content=pil_image.tobytes(),
)
image = Image(
    height=100,
    width=100,
    channels=3,
    file=file,
)
session.add(image)
session.commit() # <- will not fail even though the s3 bucket did not exist and the file upload failed

The commit will be succesfull, only later on file.get_contents() will it become clear that the save operation failed. Looking at the code it seems that this is caused by suppressing all exceptions and only doing the checks in the after_commit listener.
I was wondering what the design choices were behind this and if it is not better to do things in before_commit and let all exceptions through.

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