fluent-kit
fluent-kit copied to clipboard
Throw error if @Group key is missing
Fixes an issue causing @Group
to silently ignore missing data when decoding (#372).
@Group
will now throw an error if required data is missing while decoding. This prevents force unwrap issues due to accessing uninitialized values.
Note: It is recommended that you use DTOs to encode/decode your models from your API. Read more here: https://docs.vapor.codes/4.0/fluent/model/#data-transfer-object
This is technically semver-patch, but the change in behavior of thrown decoding errors could easily break existing error recovery logic, especially given how long this has been broken. Also people may be relying on the "ignores missing keys" behavior by now. Is it worth it to merge this?
I think it's worth adding. If anyone retrieves the group and then tries to access the property it's gonna fail right?
I'm actually not sure if you would hit the fatalError()
path that way as things stand... if so then it's not a breaking change.
@gwynne from my experience with fluent-mongo, I believe I ran into fatalError()
here.
Can be easily tested there