# error: invalid UTF-8 in string literal

- **ID:** `go/encoding-json-invalid-utf8-in-string`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

JSON input contains invalid UTF-8 byte sequences within a string, violating JSON specification.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.20 | active | — | — |
| 1.21 | active | — | — |

## Workarounds

1. **Use json.Decoder with DisallowUnknownFields and validate input** (85% success)
   ```
   decoder := json.NewDecoder(reader)
decoder.DisallowUnknownFields()
if err := decoder.Decode(&target); err != nil { /* handle */ }
   ```

## Dead Ends

- **Using strings.Replace to remove non-UTF8 characters** — May corrupt data; better to use utf8.ValidString and reject or sanitize. (70% fail)
