grpc-ecosystem/grpc-gateway · error

identifier starting with digit: %s

Error message

identifier starting with digit: %s

What it means

Identifier-validation error from expectIdent: the token that must be a proto-schema identifier begins with a digit (e.g. '1abc'). Proto identifiers must start with a letter or underscore; accept(typeIdent) rejects the token so the path template or field path cannot be parsed.

Source

Thrown at internal/httprule/parse.go:342

			return fmt.Errorf("invalid character in path segment: %q(%U)", r, r)
		}
	}
	if st != init {
		return fmt.Errorf("invalid percent-encoding in %q", t)
	}
	return nil
}

// expectIdent determines if "ident" is a valid identifier in .proto schema ([[:alpha:]_][[:alphanum:]_]*).
func expectIdent(ident string) error {
	if ident == "" {
		return errors.New("empty identifier")
	}
	for pos, r := range ident {
		switch {
		case '0' <= r && r <= '9':
			if pos == 0 {
				return fmt.Errorf("identifier starting with digit: %s", ident)
			}
			continue
		case 'A' <= r && r <= 'Z':
			continue
		case 'a' <= r && r <= 'z':
			continue
		case r == '_':
			continue
		default:
			return fmt.Errorf("invalid character %q(%U) in identifier: %s", r, r, ident)
		}
	}
	return nil
}

func isHexDigit(r rune) bool {
	switch {
	case '0' <= r && r <= '9':

View on GitHub (pinned to a58a4436a3)

Solutions

  1. Rename the field/variable so it starts with a letter or underscore.
  2. Quote nothing — http.proto templates have no quoting; adjust the template to reference a valid identifier.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/httprule/parse.go:342 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/47d42975b36369db. Report an issue: GitHub.