derailed/k9s · warning
osc52 payload exceeds encoded size limit (%d > %d)
Error message
osc52 payload exceeds encoded size limit (%d > %d)
What it means
The base64-encoded OSC52 payload exceeds the configured maximum length (osc52MaxEncodedLen, default cap overridable via an env var). The limit exists because terminals freeze or truncate on very large escape sequences, so oversized copies are refused before writing.
Source
Thrown at internal/view/clipboard.go:97
return false
}
fi, err := f.Stat()
if err != nil {
return false
}
return fi.Mode()&os.ModeCharDevice != 0
}
func writeOSC52(text string) error {
if !canTryOSC52() {
return fmt.Errorf("osc52 clipboard unavailable: stdout is not a tty or TERM=dumb")
}
encoded := base64.StdEncoding.EncodeToString([]byte(text))
maxLen := osc52MaxEncodedLen()
if len(encoded) > maxLen {
return fmt.Errorf("osc52 payload exceeds encoded size limit (%d > %d)", len(encoded), maxLen)
}
term := termValue()
seq := osc52Sequence(encoded, os.Getenv(tmuxEnv) != "", strings.HasPrefix(term, screenTermPrefix))
_, err := os.Stdout.WriteString(seq)
return err
}
func osc52MaxEncodedLen() int {
v := strings.TrimSpace(os.Getenv(osc52MaxEnv))
if v == "" {
return defaultOSC52MaxEncodedLen
}
n, err := strconv.Atoi(v)
if err != nil || n <= 0 {
return defaultOSC52MaxEncodedLen
}View on GitHub (pinned to 2d3ccc6ba2)
Solutions
- Copy a smaller slice: narrow the selection or copy a single field instead of the whole object.
- Raise/disable the cap via the documented env var (e.g. export K9S_OSC52_MAX=... style variable read in osc52MaxEnv) if your terminal handles large sequences.
- Install a system clipboard helper (xclip/pbcopy/wl-copy) so large payloads bypass OSC52 entirely.
- For big ConfigMaps/Secrets, dump to a file instead of the clipboard.
Example fix
# before export OSC52_MAX=100000 # after: raise limit for large copies export OSC52_MAX=8000000
Defensive patterns
Strategy: validation
Validate before calling
encoded := base64.StdEncoding.EncodeToString([]byte(text))
if max := osc52MaxEncodedLen(); len(encoded) > max {
return writeExternalClipboard(text) // or trim payload
} Try / catch
if err := writeOSC52(text); err != nil {
if strings.Contains(err.Error(), "exceeds encoded size limit") {
writeExternalClipboard(text)
}
} Prevention
- Clip oversized payloads before copy (single field, not whole ConfigMap).
- Set the limit env var high only if the terminal is known to handle it; otherwise keep default.
- Route large dumps to files instead of the clipboard.
When it happens
Trigger: Copying a very large payload — a big ConfigMap, a long log block, a full resource dump — such that base64 encoding pushes the sequence past the cap. Lowering the env limit makes it trigger on progressively smaller payloads.
Common situations: Copy-all on huge ConfigMaps/Secrets or full YAML of CRDs; terminals with small input buffers (some tmux/screen builds); users who set a conservative limit env var for stability.
Related errors
AI-assisted analysis of derailed/k9s@2d3ccc6ba2 (2026-08-15).
Data as JSON: /api/errors/3f70c97712f5a9a0.
Report an issue: GitHub.