googleapis/mcp-toolbox · error

unable to parse as %q: %w

Error message

unable to parse as %q: %w

What it means

ParseParameter dispatches on the 'type' field and strictly decodes the raw map into the matching parameter struct. This wrapping error fires when strict decoding rejects the entry — typically an unknown or misspelled field in the parameter block, since the strict decoder errors on unrecognized keys. The parameter type at fault is named in the message.

Source

Thrown at internal/util/parameters/parameters.go:423

	if err := validateParameter(param); err != nil {
		return nil, err
	}

	return param, nil
}

// ParseParameter parses a raw map into a Parameter object based on its "type" field.
func ParseParameter(ctx context.Context, p map[string]any, paramType string) (Parameter, error) {
	dec, err := util.NewStrictDecoder(p)
	if err != nil {
		return nil, fmt.Errorf("error creating decoder: %w", err)
	}
	switch paramType {
	case TypeString:
		a := &StringParameter{}
		if err := dec.DecodeContext(ctx, a); err != nil {
			return nil, fmt.Errorf("unable to parse as %q: %w", paramType, err)
		}
		return a, nil
	case TypeInt:
		a := &IntParameter{}
		if err := dec.DecodeContext(ctx, a); err != nil {
			return nil, fmt.Errorf("unable to parse as %q: %w", paramType, err)
		}
		if a.GetEmbeddedBy() != "" {
			return nil, fmt.Errorf("parameter type %q cannot specify 'embeddedBy'", paramType)
		}
		return a, nil
	case TypeFloat:
		a := &FloatParameter{}
		if err := dec.DecodeContext(ctx, a); err != nil {
			return nil, fmt.Errorf("unable to parse as %q: %w", paramType, err)
		}
		if a.GetEmbeddedBy() != "" {
			return nil, fmt.Errorf("parameter type %q cannot specify 'embeddedBy'", paramType)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Check the wrapped cause for the exact field name rejected by strict decoding
  2. Remove or correct misspelled/unknown fields in the parameter entry
  3. Verify the field is valid for the parameter type indicated in the message
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/util/parameters/parameters.go:423 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/e4f16fe69582c58e. Report an issue: GitHub.