vxcontrol/pentagi · error
invalid AssistantStatus: %s
Error message
invalid AssistantStatus: %s
What it means
AssistantStatus.Valid() in backend/pkg/server/models/assistants.go only accepts the defined lifecycle constants (including running, waiting, finished, failed, plus earlier states like creating defined above the excerpt). Any other value triggers this error through the GORM Validate callback when an assistant record is saved or validated.
Source
Thrown at backend/pkg/server/models/assistants.go:35
AssistantStatusFinished AssistantStatus = "finished"
AssistantStatusFailed AssistantStatus = "failed"
)
func (s AssistantStatus) String() string {
return string(s)
}
// Valid is function to control input/output data
func (s AssistantStatus) Valid() error {
switch s {
case AssistantStatusCreated,
AssistantStatusRunning,
AssistantStatusWaiting,
AssistantStatusFinished,
AssistantStatusFailed:
return nil
default:
return fmt.Errorf("invalid AssistantStatus: %s", s)
}
}
// Validate is function to use callback to control input/output data
func (s AssistantStatus) Validate(db *gorm.DB) {
if err := s.Valid(); err != nil {
db.AddError(err)
}
}
// Assistant is model to contain assistant information
// nolint:lll
type Assistant struct {
ID uint64 `form:"id" json:"id" validate:"min=0,numeric" gorm:"type:BIGINT;NOT NULL;PRIMARY_KEY;AUTO_INCREMENT"`
Status AssistantStatus `form:"status" json:"status" validate:"valid,required" gorm:"type:ASSISTANT_STATUS;NOT NULL;default:'created'"`
Title string `form:"title" json:"title" validate:"required" gorm:"type:TEXT;NOT NULL;default:'untitled'"`
Model string `form:"model" json:"model" validate:"max=70,required" gorm:"type:TEXT;NOT NULL"`
ModelProviderName string `form:"model_provider_name" json:"model_provider_name" validate:"max=70,required" gorm:"type:TEXT;NOT NULL"`View on GitHub (pinned to ea665308ba)
Solutions
- Use one of the AssistantStatus constants exactly (e.g. creating/running/waiting/finished/failed — see the type definition in assistants.go).
- Do not map statuses from other entities; AssistantStatus has its own lifecycle.
- Check casing — the switch compares exact values.
- Let the backend drive status transitions instead of setting them from client code where possible.
Example fix
// before
{"status": "stopped"}
// after
{"status": "finished"} Defensive patterns
Strategy: validation
Validate before calling
const ASSISTANT_STATUSES = ["creating", "running", "waiting", "finished", "failed"] as const;
function isValidAssistantStatus(s: string): boolean {
return (ASSISTANT_STATUSES as readonly string[]).includes(s);
}
if (!isValidAssistantStatus(input.status)) throw new Error(`invalid AssistantStatus: ${input.status}`); Type guard
function isAssistantStatus(v: unknown): v is "creating" | "running" | "waiting" | "finished" | "failed" {
return ["creating", "running", "waiting", "finished", "failed"].includes(v as string);
} Try / catch
try {
await api.updateAssistant(id, { status });
} catch (err) {
if (String(err).includes("invalid AssistantStatus")) {
console.error("Bad assistant status, allowed set in models/assistants.go:", err);
} else throw err;
} Prevention
- Avoid writing status from clients; let backend transitions drive assistant lifecycle.
- Never reuse Flow/Container status strings for assistants.
- Verify the exact constant list in assistants.go before scripting bulk updates.
- Add schema-level enum validation in the client form.
When it happens
Trigger: Creating or updating an assistant with a status string outside the AssistantStatus constants, e.g. "stopped", "pending", "ok", or an empty string; setting a status manually via API/DB.
Common situations: Integration code inventing its own status vocabulary; case-sensitivity mistakes; copying status names from a different entity (Flow/Container) that has a different state set; older clients using pre-rename status names.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- invalid UsageStatsPeriod: %s
- invalid TokenStatus: %s
- invalid ContainerType: %s
- invalid FlowStatus: %s
- invalid UserStatus: %s
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/38a8f3739a7a6f6f.
Report an issue: GitHub.