grpc/grpc-go · error

error in clientRPCEvent method

Error message

error in clientRPCEvent method: %v

What it means

Wrapping error 242: at least one entry in a client_rpc_events[].methods list failed validation. The %v carries the offending method string and the rule it broke. Only client-side (outgoing) RPC event entries produce this path.

Solutions

  1. Find the client_rpc_events entry named in the error and fix that single methods string per the <package>.<Service>/<Method> rule.
  2. Use "<package>.<Service>/*" for whole-service matching, or "*" for all methods; never "*/<method>".
  3. Validate the JSON with a linter that checks method-string shape before deploying.
  4. Restart the binary so observability.Start re-reads the corrected config.

Example fix

// before
"client_rpc_events":[{"methods":["foo.Bar","foo.Bar/Baz/Qux"]}]

// after
"client_rpc_events":[{"methods":["foo.Bar/*","foo.Bar/Baz"]}]
Defensive patterns

Strategy: validation

Validate before calling

// Reuse the same validator from error 242 on each client_rpc_events.methods entry.
for _, ev := range cfg.CloudLogging.ClientRPCEvents {
    for _, m := range ev.Methods {
        if m == "*" && ev.Exclude { return errors.New("exclude + '*' not allowed") }
        if m != "*" { if err := validateMethodString(m); err != nil { return err } }
    }
}

Try / catch

if err := observability.Start(ctx); err != nil {
    if strings.Contains(err.Error(), "clientRPCEvent method") {
        return fmt.Errorf("fix client_rpc_events entry: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: A cloud_logging.client_rpc_events item has a malformed methods entry (leading slash, missing/duplicate slash, empty method, or "*/method"). Emitted by validateLoggingEvents when iterating ClientRPCEvents during observability.Start.

Common situations: Authoring client-side logging filters by copying a fully-qualified gRPC method name with its leading slash; switching a per-service filter to a wildcard incorrectly; bad JSON produced by a config templating step.

Related errors


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

Appendix: source

Thrown at gcp/observability/config.go:97

			if exclude {
				return errors.New("cannot have exclude and a '*' wildcard")
			}
			continue
		}
		if err := validateMethodString(method); err != nil {
			return fmt.Errorf("invalid method string: %v, err: %v", method, err)
		}
	}
	return nil
}

func validateLoggingEvents(config *config) error {
	if config.CloudLogging == nil {
		return nil
	}
	for _, clientRPCEvent := range config.CloudLogging.ClientRPCEvents {
		if err := validateLogEventMethod(clientRPCEvent.Methods, clientRPCEvent.Exclude); err != nil {
			return fmt.Errorf("error in clientRPCEvent method: %v", err)
		}
	}
	for _, serverRPCEvent := range config.CloudLogging.ServerRPCEvents {
		if err := validateLogEventMethod(serverRPCEvent.Methods, serverRPCEvent.Exclude); err != nil {
			return fmt.Errorf("error in serverRPCEvent method: %v", err)
		}
	}
	return nil
}

// unmarshalAndVerifyConfig unmarshals a json string representing an
// observability config into its internal go format, and also verifies the
// configuration's fields for validity.
func unmarshalAndVerifyConfig(rawJSON json.RawMessage) (*config, error) {
	var config config
	if err := json.Unmarshal(rawJSON, &config); err != nil {
		return nil, fmt.Errorf("error parsing observability config: %v", err)
	}

View on GitHub (pinned to 0c51461d27)