wavetermdev/waveterm · error
text type requires non-empty text field
Error message
text type requires non-empty text field
What it means
AIMessagePart.Validate() rejects a part whose Type is "text" but whose Text field is empty. A text part must carry actual prompt content; an empty text part would serialize to a meaningless message part sent to the AI backend.
Source
Thrown at pkg/aiusechat/uctypes/uctypes.go:400
}
if len(m.Parts) == 0 {
return fmt.Errorf("parts must not be empty")
}
for i, part := range m.Parts {
if err := part.Validate(); err != nil {
return fmt.Errorf("part %d: %w", i, err)
}
}
return nil
}
func (p *AIMessagePart) Validate() error {
if p.Type == AIMessagePartTypeText {
if p.Text == "" {
return fmt.Errorf("text type requires non-empty text field")
}
// Check that no file fields are set
if p.FileName != "" || p.MimeType != "" || len(p.Data) > 0 || p.URL != "" {
return fmt.Errorf("text type cannot have file fields set")
}
return nil
}
if p.Type == AIMessagePartTypeFile {
if p.Text != "" {
return fmt.Errorf("file type cannot have text field set")
}
if p.MimeType == "" {
return fmt.Errorf("file type requires mimetype")
}
// Either data or url (not both) must be setView on GitHub (pinned to a4447c1563)
Solutions
- Ensure the Text field is populated with non-empty content before validating
- Skip adding the part entirely when there is no text content
- Check the client JSON payload uses the "text" key so the field unmarshals correctly
Example fix
// before
part := uctypes.AIMessagePart{Type: uctypes.AIMessagePartTypeText}
// after
if input != "" {
part := uctypes.AIMessagePart{Type: uctypes.AIMessagePartTypeText, Text: input}
} Defensive patterns
Strategy: validation
Validate before calling
func validTextPart(p uctypes.AIMessagePart) bool {
return p.Type == uctypes.AIMessagePartTypeText && p.Text != ""
} Type guard
func isTextPart(p uctypes.AIMessagePart) (string, bool) {
if p.Type == uctypes.AIMessagePartTypeText && p.Text != "" {
return p.Text, true
}
return "", false
} Prevention
- Only construct a text part when you have non-empty text
- Validate user input (trim and check) before building parts
- Call part.Validate() locally before POSTing the AIMessage
When it happens
Trigger: Calling part.Validate() or AIMessage.Validate() on an AIMessagePart with Type "text" (AIMessagePartTypeText) and Text == "", e.g. a POSTed AIMessage JSON like {"type":"text"} with no text field.
Common situations: Frontend sends a message with an empty input box; client code builds a text part but forgets to assign Text; a form submission trims user input to empty before constructing the part.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- text type cannot have file fields set
- file type cannot have text field set
- file type requires mimetype
- file type requires either data or url
- file type cannot have both data and url set
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/e38487dc5c8f55ac.
Report an issue: GitHub.