(value any)
| 238 | } |
| 239 | |
| 240 | func sanitizePluginMetadataValue(value any) (any, bool) { |
| 241 | switch v := value.(type) { |
| 242 | case nil, string, bool, float64, float32, |
| 243 | int, int8, int16, int32, int64, |
| 244 | uint, uint8, uint16, uint32, uint64: |
| 245 | return value, true |
| 246 | case map[string]any: |
| 247 | return sanitizePluginMetadata(v), true |
| 248 | case []any: |
| 249 | out := make([]any, 0, len(v)) |
| 250 | for _, item := range v { |
| 251 | if sanitized, ok := sanitizePluginMetadataValue(item); ok { |
| 252 | out = append(out, sanitized) |
| 253 | } |
| 254 | } |
| 255 | return out, true |
| 256 | default: |
| 257 | // RPC metadata crosses a JSON envelope, so unsupported Go values are normalized to JSON-compatible shapes. |
| 258 | raw, errMarshal := json.Marshal(value) |
| 259 | if errMarshal != nil { |
| 260 | return nil, false |
| 261 | } |
| 262 | var decoded any |
| 263 | if errUnmarshal := json.Unmarshal(raw, &decoded); errUnmarshal != nil { |
| 264 | return nil, false |
| 265 | } |
| 266 | return decoded, true |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | func decodeRPCEnvelope[T any](raw []byte) (T, error) { |
| 271 | var zero T |
no test coverage detected