{"record":{"id":"fe0597f338fb5adf","repo":"argoproj/argo-workflows","slug":"failed-to-marshal-container-args-for-s-w","errorCode":null,"errorMessage":"failed to marshal container args for %s: %w","messagePattern":"failed to marshal container args for (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/controller/workflowpod.go","lineNumber":814,"sourceCode":"\t\t}\n\t\tpod.Spec.Containers[i] = c\n\t}\n\n\toffloadEnvVarTemplate := false\n\toffloadContainerArgs := false\n\tvar containerArgsValue string\n\tvar containerArgsName string\n\n\t// Check if main container args need offloading (too large for exec)\n\tfor _, c := range pod.Spec.Containers {\n\t\tif common.IsArgoSidecar(c.Name) { // skip wait, supervisor, and artifact plugin sidecars\n\t\t\tcontinue\n\t\t}\n\t\tif c.Args != nil {\n\t\t\tvar argsJSON []byte\n\t\t\targsJSON, err = json.Marshal(c.Args)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to marshal container args for %s: %w\", c.Name, err)\n\t\t\t}\n\t\t\tif len(argsJSON) > common.MaxEnvVarLen {\n\t\t\t\toffloadContainerArgs = true\n\t\t\t\tcontainerArgsValue = string(argsJSON)\n\t\t\t\tcontainerArgsName = c.Name\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t// Scan every container that may carry ARGO_TEMPLATE. Legacy mode puts it on\n\t// the init container; init-less mode puts it on the supervisor (always) and\n\t// on the main container for templates without a supervisor (data /\n\t// resource-without-logs). Missing any of those when oversized re-introduces\n\t// the \"pod spec too large\" rejection that the offload path is here to fix.\n\t_ = eachContainer(pod, func(c *apiv1.Container) error {\n\t\tfor _, e := range c.Env {\n\t\t\tif e.Name == common.EnvVarTemplate {","sourceCodeStart":796,"sourceCodeEnd":832,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/controller/workflowpod.go#L796-L832","documentation":"workflowpod build could not json.Marshal a main/sidecar container's Args while checking whether they exceed the size limit for exec-based offloading. Marshal of []string args essentially cannot fail, so this is a defensive guard; the container name is included.","triggerScenarios":"json.Marshal(c.Args) returns an error — practically only for unsupported values in args; args are []string so this is nearly unreachable except via corrupted/programmatically built templates, or an oversized/odd arg payload path in custom code.","commonSituations":"Template specs generated by tooling that inject non-string arg values; bugs in controllers/plugins mutating pod specs; extremely large args arrays interacting with MaxEnvVarLen offload logic.","solutions":["Inspect the wrapped marshal error in the controller log","Ensure template container args are plain strings in the Workflow spec","Validate the Workflow with argo lint before submitting","Check for custom controllers/operators mutating the workflow pod spec"],"exampleFix":"// before\nargs: [\"--flag\", 42]\n// after\nargs: [\"--flag\", \"42\"]","handlingStrategy":"validation","validationCode":"// args must be an array of strings in the template spec\n// argo lint my-wf.yaml","typeGuard":null,"tryCatchPattern":"if argsJSON, err := json.Marshal(c.Args); err != nil {\n    return nil, fmt.Errorf(\"failed to marshal container args for %s: %w\", c.Name, err)\n}","preventionTips":["Keep container args as plain strings in manifests","Lint generated workflows before submission","Audit custom tooling that mutates template specs"],"tags":["json","serialization","container-args"],"backgroundTag":"json-marshal-failed","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}