grafana/k6 · error

invalid reflectMetadata param

Error message

invalid reflectMetadata param: %w

What it means

Raised in newConnectParams when the 'reflectMetadata' option of grpc.connect fails newMetadata conversion — must be an object of string-to-string (or '-bin' to binary) pairs; the wrapped error gives specifics.

Solutions

  1. Pass reflectMetadata as a plain object of string keys to string values
  2. Use '-bin' keys with byte arrays for binary metadata
  3. Check the wrapped error for the failing entry
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/js/modules/k6/grpc/params.go:180 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/8d3e9cb885d7a0f8. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/grpc/params.go:180

			if !ok {
				return result, fmt.Errorf("invalid plaintext value: '%#v', it needs to be boolean", v)
			}
		case "timeout":
			var err error
			result.Timeout, err = types.GetDurationValue(v)
			if err != nil {
				return result, fmt.Errorf("invalid timeout value: %w", err)
			}
		case "reflect":
			var ok bool
			result.UseReflectionProtocol, ok = v.(bool)
			if !ok {
				return result, fmt.Errorf("invalid reflect value: '%#v', it needs to be boolean", v)
			}
		case "reflectMetadata":
			md, err := newMetadata(params.Get(k))
			if err != nil {
				return result, fmt.Errorf("invalid reflectMetadata param: %w", err)
			}

			result.ReflectionMetadata = md
		case "maxReceiveSize":
			var ok bool
			result.MaxReceiveSize, ok = v.(int64)
			if !ok {
				return result, fmt.Errorf("invalid maxReceiveSize value: '%#v', it needs to be an integer", v)
			}
			if result.MaxReceiveSize < 0 {
				return result, fmt.Errorf("invalid maxReceiveSize value: '%#v, it needs to be a positive integer", v)
			}
		case "maxSendSize":
			var ok bool
			result.MaxSendSize, ok = v.(int64)
			if !ok {
				return result, fmt.Errorf("invalid maxSendSize value: '%#v', it needs to be an integer", v)
			}

View on GitHub (pinned to 01ffac6f24)