Xuanwo opened a new pull request, #8921:
URL: https://github.com/apache/opendal/pull/8921

   # Which issue does this PR close?
   
   None. Found during maintenance; no separate issue was filed.
   
   # Rationale for this change
   
   `op:write` rejected every payload that was not valid UTF-8.
   
   The binding converted the payload argument to `String`, and `mlua` validates 
UTF-8 for that conversion. Lua strings are raw byte sequences with no encoding 
attached, so this rejected legitimate payloads. Both of these failed on `main`:
   
   ```lua
   op:write("a", "\0\255\128bin")
   -- bad argument #3: error converting Lua string to String (invalid utf-8 
sequence of 1 bytes from index 1)
   
   op:write("b", op:read("a"))
   -- same error for any binary content that read returned
   ```
   
   The constraint was also inconsistent inside the binding. `op:read` already 
returns `LuaString` built from raw bytes, and `src/operator_doc.lua` documents 
`write` as "Blockingly write raw bytes to path". Only `write` narrowed its 
payload to UTF-8.
   
   # What changes are included in this PR?
   
   - `bindings/lua/src/lib.rs`: `operator_write` takes the payload as 
`LuaString` and hands `as_bytes()` to the operator, so arbitrary byte sequences 
reach storage unchanged.
   - `bindings/lua/test/opendal_test.lua`: adds an `opendal binary payload` 
suite covering a payload with non-UTF-8 bytes and an embedded NUL 
(`"\0\255\128bin"`), a write of bytes returned by `op:read`, and unchanged 
UTF-8 text handling.
   
   Path arguments intentionally stay `String` because OpenDAL object paths are 
UTF-8. Every function the binding exposes was audited for the same mistake: 
`write` was the only one carrying a file payload, the rest take paths, a 
scheme, or option values.
   
   The two binary cases fail with the error above before this change and pass 
after it; the UTF-8 case passes in both.
   
   # Are there any user-facing changes?
   
   Yes. `op:write` now accepts arbitrary binary payloads, including bytes that 
are not valid UTF-8 and embedded NUL bytes. UTF-8 text behaves exactly as 
before, and no API shape changed.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: T3 Code orchestrating the Pi coding agent
   - Model: DeepSeek V4.1 Flash
   - Effort: max
   - Role: Authored the binding change and the Lua regression tests, and ran 
the Lua binding checks from `.github/workflows/ci_bindings_lua.yml` on a host 
with the same toolchain (Lua 5.2, luarocks, busted). The tests exercise the 
memory service, matching the existing Lua suite; no remote storage service was 
involved.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to