Fix XML encoding #62
Labels
No labels
action
check-aws
action
discussion-needed
action
for-external-contributors
action
for-newcomers
action
more-info-needed
action
need-funding
action
triage-required
kind
correctness
kind
ideas
kind
improvement
kind
performance
kind
testing
kind
usability
kind
wrong-behavior
prio
critical
prio
low
scope
admin-api
scope
background-healing
scope
build
scope
documentation
scope
k8s
scope
layout
scope
metadata
scope
ops
scope
rpc
scope
s3-api
scope
security
scope
telemetry
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Deuxfleurs/garage#62
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Decoding of XML in S3 requests is done using a proper library,
roxmltree
.Encoding however is not, it is currently produced in an ad-hoc manner which is prone to many bug. We should fix this.
This issue has the "Bug" tag because it probably causes issues, like #59 for instance
Could we use serde_xml_rs?
@quentin yes serde_xml_rs might be an option, however I'm not sure it easily supports things such as adding a
<?xml version="1.0" encoding="UTF-8"?>
header at the beginning, or customxmlns
attributes. Also the variables in Rust structs are typically named insnake_case
but XML tag names in S3's format usually useCamelCase
. So if we use Serde that probably means crating custom structs for encoding, adding a whole bunch of attributes so that it does what we want (which might be badly documented or just plain impossible), and then translating our data into these structs before serializing. My intuition is that we can probably have something much more straightforward with a programmatic interface, i.e. a simple XML builder object with methods such as: add header, open tag, add attribute, add text value, etc.Here are two examples of crates in this spirit:
There is also this crates that includes both serialization and deserialization in a similar spirit, and could maybe used to do both and thus replace our curent dependency on
roxmltree
for parsing:Of course serde_xml_rs is still an option if we can make it work.
If it were me I'd probably go with just
xmlwriter
because we can trivially replace the current XML serialization with that as it works the same, just ensuring that the produced XML has the right structure and is encoded correctly.I tried
serde_xml_rs
and it seems to miss many many features plus it has been reported being slow.Currently, I have a proof of concept running with serde + quick_xml here: https://git.deuxfleurs.fr/Deuxfleurs/garage/src/branch/feature/s3/list-buckets/src/api/s3_bucket.rs#L77-L111
It addresses the issues you mentionned.
The advantage I see by using serde is that, even if we are a bit more verbose, we write code that is declarative and not imperative which make it easier to read it in my opinion.
Fixed by #74