Repository navigation
fix(bindings/go,dotnet)!: preserve explicit empty string options - #9575
Conversation
chitralverma
left a comment
There was a problem hiding this comment.
Review of head e578dd6c7.
Blocking
OpenDALMetadata.csis generated. The generator still emitswriter.Utf8(...)(dev/src/generate/dotnet.rs:450), and this PR deletesNativeOptionsWriter.Utf8. On the PR head,generate -l dotnetfollowed bycargo fmtchanges all 8 lines back towriter.Utf8(...). Socheck_generatedfails, and the next regeneration breaks the .NET build. Fix: emitwriter.String(...)atdotnet.rs:450.
Non-blocking
-
Empty ETag on services that support
if_match. The new tests use memory and fs. Both rejectif_matchasUnsupportedbefore any request. On S3, GCS and Azure Blob, the empty value reaches the request unchanged:OpWrite::checkchecks onlyif_match().is_some()(core/core/src/raw/ops.rs:1386), ands3_put_object_request,gcs_insert_object_xml_requestandazblob_put_blob_requestset an emptyIf-Matchheader. Some HTTP servers treat an emptyIf-Matchas absent. Go'snet/httpcheckIfMatchis one. I did not test a real storage service. If one ignores the empty header,WriteWithIfMatch("")still overwrites. Rustif_match("")reaches the same path, so a core follow-up can fix all bindings, for example by rejecting an empty ETag withConfigInvalid. -
.NET API docs. The Go generator adds "An empty string is an explicit value. Omit this option to leave it unset." to each string option. The .NET XML docs, for example
WriteOptions.IfMatch, do not state thenullversus""rule. Only the README does.options_cs.j2renders onlyp.summary, so this needs a generator change.
Checked, no findings: generate -l c gives no diff. dev tests pass (199). In Go and .NET, an explicit "" reaches core as Some("").
This comment is AI assisted.
chitralverma
left a comment
There was a problem hiding this comment.
89556ba5a fixes findings 1 and 3. On this head, generate -l dotnet and generate -l c, followed by cargo fmt, give no diff. The dev tests pass (199). All 50 optional string properties in the .NET options classes now have the null versus "" remark.
Finding 2 (empty If-Match on services that support if_match) belongs in core and does not block this PR.
This comment is AI assisted.
|
Follow-up for finding 2: core still sends This comment is AI assisted. |
Which issue does this PR close?
Closes #9555.
Rationale for this change
Passing an empty
IfMatchin Go or .NET could drop the precondition and let a write overwrite existing data. In .NET it could also let a delete remove the object.What changes are included in this PR?
The Go generator records whether a caller supplied each string option and passes explicit strings through the existing C setters, keeping borrowed bytes alive through the operation. The .NET options writer uses one UTF-8 encoder that maps
nullto a null pointer and writes a terminator for an empty string. The .NET generator uses the same encoder for metadata and documents the distinction on the generated option properties. Generator review by Chitral VermaThe memory tests confirm that empty and nonempty ETag preconditions on an unsupported operation return
Unsupportedand preserve the stored bytes. The .NETContentTypetest also reads back the three string states throughStat.Are there any user-facing changes?
An explicit empty string now reaches OpenDAL as an option value. It goes through the same capability checks as other supplied values.
Breaking changes
Affected packages: bindings/go, bindings/dotnet
Migration:
WriteWithIfMatch(etag)only when the caller supplied an ETag.WriteWithIfMatch("")now requests a conditional write.nullto omit them. Convert empty placeholders tonullwhere they represented missing values.AI Usage Statement
magpie/codex/gpt-6.2-astra. Effort:thinking=high. Role: Traced option forwarding, checked the C ABI boundary, and designed the regression coverage.magpie/codex/gpt-6.2-sol. Effort:thinking=max. Role: Implemented the fix, reproduced the regression on matching native builds, and verified the bindings and generator.magpie/codex/gpt-6.2-sol. Effort:thinking=high. Role: Independently reviewed the binding change and verified public API regressions against matching native builds.