larksuite/cli · error
content safety panic: %v
Error message
content safety panic: %v
What it means
The output emit pipeline runs the content-safety provider Scan inside a goroutine whose deferred recover converts a panic into an error "content safety panic: %v" delivered over the result channel. It exists so a crashing safety scanner never takes down the CLI; the panic text is preserved for diagnosis.
Source
Thrown at internal/output/emit_core.go:103
return nil, nil
}
type result struct {
alert *extcs.Alert
err error
}
ch := make(chan result, 1)
ctx, cancel := context.WithTimeout(context.Background(), scanTimeout)
defer cancel()
// Give the goroutine its own writer so it cannot race on errOut after timeout.
// On success, we copy any provider notices to the real errOut.
// On timeout, the buffer is owned by the goroutine until it finishes; no shared access.
scanErrBuf := &bytes.Buffer{}
go func() {
defer func() {
if r := recover(); r != nil {
ch <- result{nil, fmt.Errorf("content safety panic: %v", r)}
}
}()
a, e := p.Scan(ctx, extcs.ScanRequest{Path: cmdPath, Data: data, ErrOut: scanErrBuf})
ch <- result{a, e}
}()
var res result
select {
case res = <-ch:
if scanErrBuf.Len() > 0 {
_, _ = io.Copy(errOut, scanErrBuf)
}
case <-ctx.Done():
return nil, nil // timeout, fail-open; scanErrBuf stays with the goroutine
}
if res.err != nil {
fmt.Fprintf(errOut, "warning: content safety scan error: %v\n", res.err)View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Read the %v panic value and stack context to find the panicking provider code.
- Reproduce with the same command output to identify the triggering input.
- Update/fix the safety provider implementation (the panic is the real bug; this envelope is just the safety net).
- As an operator workaround, disable/replace the content-safety provider if your distribution allows it.
Defensive patterns
Strategy: try-catch
Try / catch
if err := emit(...); err != nil {
if strings.HasPrefix(err.Error(), "content safety panic:") {
log.Printf("safety scanner crashed, output suppressed: %v", err)
// report bug upstream / fall back to raw output if policy allows
}
} Prevention
- Keep the content-safety provider updated
- Avoid piping pathological output (huge/binary) through scanners when possible
- Report panic values from this envelope as provider bugs — the recover is a safety net
When it happens
Trigger: p.Scan panics during content-safety scanning of command output — e.g. a nil dereference or index panic inside the provider implementation on some input, or misuse of ScanRequest fields.
Common situations: Unusual command output (binary, huge payloads, odd encodings) triggering an edge-case bug in the scanner; a custom/patched safety provider with a bug; concurrent misuse of shared provider state.
Related errors
- %v
- hook %q panic: %v
- Invalid column: {column!r}
- Invalid column index: {index}
- anchor outside sheet: {position!r}
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/71afc60d0e22cf76.
Report an issue: GitHub.