Round-tripping fails for collapsable object held as Optional
using URLEncodedFormEncoder
/ Decoder
#3329
Labels
bug
Something isn't working
Describe the issue
When holding a potentially empty (“collapsable”) object as an
Optional
, round-tripping withURLEncodedFormEncoder
/Decoder
fails.Vapor version
4.114.1
Operating system and version
macOS 15.3
Swift version
swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
Steps to reproduce
When holding a potentially empty (“collapsable”) object as an
Optional
, round-tripping withURLEncodedFormEncoder
/Decoder
fails.By “collapsable”, I mean that the encoded result of the object can become empty.
Here’s an example:
This object has two properties. When
optional
is.none
andarray
is empty, encoding it usingURLEncodedFormEncoder
results in an empty string.Now, consider an object holding this as an
Optional
:When this object holds a
Collapsable
instance, encoding and then decoding it usingURLEncodedFormEncoder
andURLEncodedFormDecoder
does not preserve the original value when theCollapsable
becomes empty:Is this the intended behavior?
Outcome
No response
Additional notes
I have uploaded a runnable example here for your reference if needed:
https://github.com/omochi/vapor/blob/0c4ddbc7605a33a3e8bb05af1f7e88547a526329/Tests/VaporTests/URLEncodedFormTests.swift#L54-L62
The text was updated successfully, but these errors were encountered: