Eason09053360 commented on code in PR #75601:
URL: https://github.com/apache/airflow/pull/75601#discussion_r4436205616
##########
go-sdk/pkg/execution/client.go:
##########
@@ -529,26 +540,47 @@ func resolveExpiry(retention *time.Duration, now
time.Time) (any, error) {
// validateJSONRepresentable checks what the frame encoder actually emits, not
// the Go value: a reflection walk has to mirror the encoder's field rules
(tags,
// "-", omitempty, embedding, marshalers) and misjudges values wherever it
drifts.
-func validateJSONRepresentable(value any) error {
+// On success it also returns the decoded value, which is nil when value
encodes
+// to null.
+func validateJSONRepresentable(value any) (any, error) {
var buf bytes.Buffer
if err := newFrameEncoder(&buf).Encode(value); err != nil {
- return fmt.Errorf("%T is not JSON representable: %w", value,
err)
+ return nil, fmt.Errorf("%T is not JSON representable: %w",
value, err)
}
dec := msgpack.NewDecoder(&buf)
- // The default map decoder fails opaquely on non-string keys.
- dec.SetMapDecoder(func(d *msgpack.Decoder) (any, error) {
- return d.DecodeUntypedMap()
- })
+ dec.SetMapDecoder(decodeStringKeyedMap)
decoded, err := dec.DecodeInterface()
if err != nil {
- return fmt.Errorf("%T is not JSON representable: %w", value,
err)
+ return nil, fmt.Errorf("%T is not JSON representable: %w",
value, err)
}
- // Checked after decoding: a typed nil such as a nil *string is not ==
nil,
- // yet it still encodes to null, which the Execution API rejects.
- if decoded == nil {
- return errors.New("value must not be nil")
+ if err := validateDecodedValue(decoded); err != nil {
+ return nil, err
}
- return validateDecodedValue(decoded)
+ return decoded, nil
+}
Review Comment:
Applied in c43c7be, thanks!
--
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]