{"record":{"id":"c3bdc54633550dfb","repo":"vxcontrol/pentagi","slug":"invalid-containerstatus-s","errorCode":null,"errorMessage":"invalid ContainerStatus: %s","messagePattern":"invalid ContainerStatus: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/server/models/containers.go","lineNumber":34,"sourceCode":"\tContainerStatusDeleted  ContainerStatus = \"deleted\"\n\tContainerStatusFailed   ContainerStatus = \"failed\"\n)\n\nfunc (s ContainerStatus) String() string {\n\treturn string(s)\n}\n\n// Valid is function to control input/output data\nfunc (s ContainerStatus) Valid() error {\n\tswitch s {\n\tcase ContainerStatusStarting,\n\t\tContainerStatusRunning,\n\t\tContainerStatusStopped,\n\t\tContainerStatusDeleted,\n\t\tContainerStatusFailed:\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid ContainerStatus: %s\", s)\n\t}\n}\n\n// Validate is function to use callback to control input/output data\nfunc (s ContainerStatus) Validate(db *gorm.DB) {\n\tif err := s.Valid(); err != nil {\n\t\tdb.AddError(err)\n\t}\n}\n\ntype ContainerType string\n\nconst (\n\tContainerTypePrimary   ContainerType = \"primary\"\n\tContainerTypeSecondary ContainerType = \"secondary\"\n)\n\nfunc (t ContainerType) String() string {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/server/models/containers.go#L16-L52","documentation":"ContainerStatus.Valid() in backend/pkg/server/models/containers.go accepts only the ContainerStatus constants (running, stopped, deleted, failed, plus the initial state defined above the excerpt). Any other value fails the GORM Validate callback with this message.","triggerScenarios":"Writing or filtering a sandbox container record with a status like \"exited\", \"killed\", \"paused\", or empty string; passing raw Docker engine status strings straight into the API.","commonSituations":"Mapping Docker daemon status (created/running/paused/restarting/removing/exited/dead) directly into PentAGI's model; client-side assumption of extra states; typos or casing mismatches in tool/integration code.","solutions":["Translate raw Docker states to ContainerStatus constants (e.g. exited -> stopped, dead -> failed, removing -> deleted).","Use one of the exact ContainerStatus values defined in containers.go.","Fix casing and whitespace in the submitted value.","Update integrations that predate a status rename to the current constant set."],"exampleFix":"// before\n{\"status\": \"exited\"}\n// after\n{\"status\": \"stopped\"}","handlingStrategy":"validation","validationCode":"function dockerStatusToContainerStatus(d: string): string | null {\n  const map = { created: \"created\", running: \"running\", paused: \"stopped\", exited: \"stopped\", dead: \"failed\", removing: \"deleted\" };\n  return (map as Record<string, string>)[d] ?? null; // null means it needs manual mapping\n}\nconst status = dockerStatusToContainerStatus(rawStatus);\nif (!status) throw new Error(`unmapped docker status: ${rawStatus}`);","typeGuard":"function isContainerStatus(v: unknown): v is \"created\" | \"running\" | \"stopped\" | \"deleted\" | \"failed\" {\n  return [\"created\", \"running\", \"stopped\", \"deleted\", \"failed\"].includes(v as string);\n}","tryCatchPattern":"try {\n  await api.createContainer({ name, status: rawStatus });\n} catch (err) {\n  if (String(err).includes(\"invalid ContainerStatus\")) {\n    // fall back to a safe, always-valid state after translating\n    await api.createContainer({ name, status: \"stopped\" });\n  } else throw err;\n}","preventionTips":["Always translate raw Docker engine states through a mapping table before calling the API.","Keep the mapping table next to the ContainerStatus constants and update both together.","Log unmapped states instead of passing them through.","Test integrations with containers that end in each Docker state."],"tags":["validation","enum","docker","containers"],"backgroundTag":"invalid-enum-value","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}