larksuite/cli · error
unsupported charset %q
Error message
unsupported charset %q
What it means
encodeTextCharset: the draft's charset label is not UTF-8-like and htmlcharset.Lookup has no matching encoder, so the outgoing MIME part cannot be encoded; an intermediate error the mail command layer wraps into a typed ValidationError.
Source
Thrown at shortcuts/mail/draft/charset.go:52
func decodeTextCharset(body []byte, label string) ([]byte, error) {
if isUTF8LikeCharset(label) {
return body, nil
}
reader, err := htmlcharset.NewReaderLabel(label, bytes.NewReader(body))
if err != nil {
return nil, err
}
return io.ReadAll(reader)
}
func encodeTextCharset(body []byte, label string) ([]byte, error) {
if isUTF8LikeCharset(label) {
return body, nil
}
enc, _ := htmlcharset.Lookup(label)
if enc == nil {
return nil, fmt.Errorf("unsupported charset %q", label) //nolint:forbidigo // intermediate draft charset error; mail command layer wraps into typed ValidationError.
}
var buf bytes.Buffer
writer := transform.NewWriter(&buf, enc.NewEncoder())
if _, err := writer.Write(body); err != nil {
_ = writer.Close()
return nil, err
}
if err := writer.Close(); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Use UTF-8 or another alias recognized by htmlcharset (e.g. gb18030, iso-8859-1)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at shortcuts/mail/draft/charset.go:52 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/ca29b26f3fab26f0.
Report an issue: GitHub.