isFantasyEnvelopeFormat checks whether raw message content uses the fantasy envelope format (legacy) vs SDK parts (new). It examines the first array element for a "data" field containing a JSON object (starts with '{'). Fantasy always serializes Data from json.Marshal(struct{...}), producing a JSON
(raw json.RawMessage)
| 1211 | // means a "data" field starting with '{' can only come from |
| 1212 | // fantasy. |
| 1213 | func isFantasyEnvelopeFormat(raw json.RawMessage) bool { |
| 1214 | var arr []json.RawMessage |
| 1215 | if err := json.Unmarshal(raw, &arr); err != nil || len(arr) == 0 { |
| 1216 | return false |
| 1217 | } |
| 1218 | var fields map[string]json.RawMessage |
| 1219 | if err := json.Unmarshal(arr[0], &fields); err != nil { |
| 1220 | return false |
| 1221 | } |
| 1222 | data, ok := fields["data"] |
| 1223 | if !ok { |
| 1224 | return false |
| 1225 | } |
| 1226 | trimmed := bytes.TrimSpace(data) |
| 1227 | return len(trimmed) > 0 && trimmed[0] == '{' |
| 1228 | } |
| 1229 | |
| 1230 | // marshalProviderMetadata converts fantasy provider metadata to raw |
| 1231 | // JSON for storage in SDK parts. |
no test coverage detected