grpc/grpc-go · warning

invalid config: %q, %v

Error message

invalid config: %q, %v

What it means

Returned by fillMethodLoggerWithConfigString when parsing a blacklist entry (config starting with '-'), parseMethodConfigAndSuffix fails to match the expected service/method format (env_config.go:69-72). The part after '-' must match the regex ^([\w./]+)/((?:\w+)|[*])(.+)?$ which requires a 'service/method' structure. The %q is the full config token; %v is the parse error.

Source

Thrown at internal/binarylog/env_config.go:72

			return nil
		}
	}
	return l
}

// fillMethodLoggerWithConfigString parses config, creates TruncatingMethodLogger and adds
// it to the right map in the logger.
func (l *logger) fillMethodLoggerWithConfigString(config string) error {
	// "" is invalid.
	if config == "" {
		return errors.New("empty string is not a valid method binary logging config")
	}

	// "-service/method", blacklist, no * or {} allowed.
	if config[0] == '-' {
		s, m, suffix, err := parseMethodConfigAndSuffix(config[1:])
		if err != nil {
			return fmt.Errorf("invalid config: %q, %v", config, err)
		}
		if m == "*" {
			return fmt.Errorf("invalid config: %q, %v", config, "* not allowed in blacklist config")
		}
		if suffix != "" {
			return fmt.Errorf("invalid config: %q, %v", config, "header/message limit not allowed in blacklist config")
		}
		if err := l.setBlacklist(s + "/" + m); err != nil {
			return fmt.Errorf("invalid config: %v", err)
		}
		return nil
	}

	// "*{h:256;m:256}"
	if config[0] == '*' {
		hdr, msg, err := parseHeaderMessageLengthConfig(config[1:])
		if err != nil {
			return fmt.Errorf("invalid config: %q, %v", config, err)

View on GitHub (pinned to 0c51461d27)

Solutions

  1. Use the format '-service/method' for blacklist entries (e.g., '-Foo/Bar')
  2. Ensure both service and method parts are present and separated by a forward slash
  3. Validate each comma-separated token against the expected format before setting the env var

Example fix

# before (malformed blacklist entry)
export GRPC_BINARY_LOG_FILTER="-Foo"

# after (valid format)
export GRPC_BINARY_LOG_FILTER="-Foo/Bar"
Defensive patterns

Strategy: validation

Validate before calling

// Validate blacklist entry format before using the config string
func validateBlacklistEntry(entry string) error {
    if !strings.HasPrefix(entry, "-") {
        return nil
    }
    rest := entry[1:]
    matched, _ := regexp.MatchString(`^[\w./]+/(?:\w+|[*])(?:\{.*\})?$`, rest)
    if !matched {
        return fmt.Errorf("blacklist entry %q does not match 'service/method' format", entry)
    }
    return nil
}

Prevention

When it happens

Trigger: A blacklist entry in GRPC_BINARY_LOG_FILTER where the part after '-' does not match 'service/method'. For example, '-Foo' (no slash or method), '-invalid', or '-/Bar' (no service). parseMethodConfigAndSuffix returns 'contains invalid substring' when the regex does not match.

Common situations: Typos in blacklist entries in the environment variable. Misunderstanding the required 'service/method' format for blacklist entries.

Related errors


AI-assisted analysis of grpc/grpc-go@0c51461d27 (2026-08-11). Data as JSON: /api/errors/d131b0d0db997b94. Report an issue: GitHub.