grafana/k6 · error

unsupported type: %T

Error message

unsupported type: %T

What it means

Thrown by fillData when a Blob part element is of an unsupported type. The type switch covers byte/int/uint/float slices, ArrayBuffers, strings, and DataView/TypedArray-like objects; any other element kind (e.g. a plain number, boolean, or arbitrary object) reaches the default branch and its Go type is reported. Aborts Blob construction immediately.

Solutions

  1. Use only supported part types: strings, ArrayBuffers, TypedArrays (via their buffer), or another Blob
  2. Wrap scalar values as strings: new Blob([String(n)])
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at internal/js/modules/k6/websockets/blob.go:130 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/7f06f19bfa1ef733. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/websockets/blob.go:130

			case []uint8:
				_, err = b.data.Write(v)
			case []int8, []int16, []int32, []int64, []uint16, []uint32, []uint64, []float32, []float64:
				err = binary.Write(b.data, binary.LittleEndian, v)
			case sobek.ArrayBuffer:
				_, err = b.data.Write(v.Bytes())
			case *sobek.ArrayBuffer:
				_, err = b.data.Write(v.Bytes())
			case string:
				_, err = b.data.WriteString(v)
			case map[string]any:
				obj := call.Arguments[0].ToObject(rt).Get(strconv.FormatInt(int64(n), 10)).ToObject(rt)
				switch {
				case isDataView(obj, rt):
					_, err = b.data.Write(obj.Get("buffer").Export().(sobek.ArrayBuffer).Bytes()) //nolint:forcetypeassert
				case isBlob(obj, r.blobConstructor):
					_, err = b.data.Write(extractBytes(obj, rt))
				default:
					err = fmt.Errorf("unsupported type: %T", part)
				}
			default:
				err = fmt.Errorf("unsupported type: %T", part)
			}
			if err != nil {
				common.Throw(rt, fmt.Errorf("failed to process [blobParts]: %w", err))
			}
		}
	}
}

func (r *WebSocketsAPI) slice(call sobek.FunctionCall, b *blob, rt *sobek.Runtime) sobek.Value {
	var (
		from int
		to   = b.data.Len()
		ct   = ""
	)

View on GitHub (pinned to 01ffac6f24)