You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Uploading a file from an in-memory stream is impossible: both code paths are broken #140
The assignment happens before the model is initialised:
>>> InMemoryController(stream=io.BytesIO(b"hi"))
AttributeError: 'osw.controller.file.memory.InMemoryController' object has no attribute '__iris__'
It also unconditionally overwrites a caller-supplied stream with an empty StringIO, and defaults to StringIO where the put/get counterparts are byte-oriented.
Suggested fix
Replace the isinstance(source, IO) check with a duck-typed one (hasattr(source, "read")), or use typing.BinaryIO/io.IOBase.
Drop the custom __init__ so pydantic assigns stream from kwargs, or set the default via a field default rather than in __init__.
Add a test that round-trips a BytesIO through upload_file.
Context: found while planning the path-free MCP file tools (#133). That work routes around both by calling WikiFileController.put(file: IO) directly, so it is not blocked by this, but the public express API stays broken.
Activity