grpc-ecosystem/grpc-gateway · error

invalid field path component: %w

Error message

invalid field path component: %w

What it means

Parser error from parser.fieldPath: after a '.' separator inside a variable's field path, the next token is not a valid identifier (expectIdent failed). A template like '{a..b}' or '{a.123}' is rejected; the wrapped error identifies the bad component.

Source

Thrown at internal/httprule/parse.go:222

	return variable{
		path:     path,
		segments: segs,
	}, nil
}

func (p *parser) fieldPath() (string, error) {
	c, err := p.accept(typeIdent)
	if err != nil {
		return "", err
	}
	components := []string{c}
	for {
		if _, err := p.accept("."); err != nil {
			return strings.Join(components, "."), nil
		}
		c, err := p.accept(typeIdent)
		if err != nil {
			return "", fmt.Errorf("invalid field path component: %w", err)
		}
		components = append(components, c)
	}
}

// A termType is a type of terminal symbols.
type termType string

// These constants define some of valid values of termType.
// They improve readability of parse functions.
//
// You can also use "/", "*", "**", "." or "=" as valid values.
const (
	typeIdent   = termType("ident")
	typeLiteral = termType("literal")
	typeEOF     = termType("$")
)

View on GitHub (pinned to a58a4436a3)

Solutions

  1. Ensure each dot-separated component of the field path is a valid proto identifier (letter/underscore first, alphanumerics after).
  2. Remove stray dots from the variable expression.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/httprule/parse.go:222 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grpc-ecosystem/grpc-gateway@a58a4436a3 (2026-09-02). Data as JSON: /api/errors/3d641bb5a44ff46d. Report an issue: GitHub.