# rpc error: code = Internal desc = grpc: error while marshaling: proto: syntax error (line 1:1): unexpected token

- **ID:** `go/grpc-internal-error-marshalling`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The protobuf message being sent is malformed or does not match the schema, causing marshalling failure.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.0 | active | — | — |
| 1.1 | active | — | — |

## Workarounds

1. **Validate the protobuf message before sending.** (85% success)
   ```
   req := &pb.MyRequest{Name: "test"}
if err := req.Validate(); err != nil {
    log.Fatalf("invalid request: %v", err)
}
// Use proto.Marshal to check if marshalling works
if _, err := proto.Marshal(req); err != nil {
    log.Fatalf("marshal error: %v", err)
}
   ```
2. **Ensure the protobuf library version matches the generated code.** (80% success)
   ```
   Check go.mod for google.golang.org/protobuf version and run 'go mod tidy' to sync.
   ```

## Dead Ends

- **Ignore the error and retry the same request.** — The same malformed message will cause the same error repeatedly. (100% fail)
- **Change the protobuf field types without updating the definition.** — Field types are fixed in the .proto file; changing them manually leads to incompatibility. (95% fail)
