sipeed/picoclaw · error
channel failed to decode settings
Error message
channel %q failed to decode settings: %w
What it means
Channel.GetDecoded lazily decodes the channel's raw Settings into the typed settings struct for its channel type; the raw settings did not match the expected schema for that channel type. The decoded value (possibly nil) is still returned alongside the error so callers can distinguish 'not decoded yet' from 'decode failed'.
Solutions
- Compare the channel's settings in config.json against the documented schema for that channel type
- Remove or fix unknown/mistyped settings fields
- Re-run channel init after editing; the decode is lazy and will retry on next access
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at pkg/config/config_channel.go:353 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15).
Data as JSON: /api/errors/87a1658139814715.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/config/config_channel.go:353
return fmt.Errorf("target is nil")
}
if err := b.Settings.Decode(target); err != nil {
return err
}
b.extend = target
return nil
}
// GetDecoded returns the previously decoded settings struct.
// If Decode hasn't been called yet, it lazily decodes using the channel Type prototype.
// Returns an error if decoding fails; the decoded value (possibly nil) is still returned
// so callers can distinguish between "not decoded" and "decode failed".
func (b *Channel) GetDecoded() (any, error) {
if b.extend == nil {
// fallback to prototype-based creation
if target := newChannelSettings(b.Type); target != nil {
if err := b.Decode(target); err != nil {
return nil, fmt.Errorf("channel %q failed to decode settings: %w", b.name, err)
}
}
}
return b.extend, nil
}
// UnmarshalYAML implements yaml.Unmarshaler for Channel.
// Merges the YAML node into the existing Channel.
// Supports both nested format (settings: {...}) and flat format (token: xxx).
func (b *Channel) UnmarshalYAML(value *yaml.Node) error {
if value.Kind == 0 {
return nil
}
type alias Channel
a := alias(*b)
err := value.Decode(&a)
if err != nil {View on GitHub (pinned to 49183d7e8d)