# proto: (line 1:14): unknown field "userName"

- **ID:** `go/protobuf-json-unknown-field`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

protojson.Unmarshal encountered a JSON key that does not match any field in the target message. protobuf JSON uses either the proto field name (snake_case) or the lowerCamelCase JSON name; using an unrelated casing fails.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| google.golang.org/protobuf 1.28+ | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   opts := protojson.UnmarshalOptions{DiscardUnknown: true}
if err := opts.Unmarshal(data, msg); err != nil {
    return err
}
   ```
2. **** (88% success)
   ```
   // .proto: string user_name = 1;
// JSON accepts either:
// {"user_name":"alice"}  or  {"userName":"alice"}
   ```

## Dead Ends

- **** — encoding/json ignores protobuf-specific semantics (oneofs, well-known types) and produces incorrect values. (80% fail)
- **** — Fragile and breaks for nested messages, repeated fields, and oneofs; also loses type info. (60% fail)
