{"record":{"id":"d6c79dd6af1f93f2","repo":"argoproj/argo-workflows","slug":"invalidargument-d6c79d","errorCode":"InvalidArgument","errorMessage":"cluster workflow template was not found in the request body","messagePattern":"cluster workflow template was not found in the request body","errorType":"error_code","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/clusterworkflowtemplate/cluster_workflow_template_server.go","lineNumber":39,"sourceCode":")\n\ntype Server struct {\n\tinstanceIDService instanceid.Service\n\tcwftmplStore      servertypes.ClusterWorkflowTemplateStore\n\twfDefaults        *v1alpha1.Workflow\n}\n\nfunc NewClusterWorkflowTemplateServer(instanceID instanceid.Service, cwftmplStore servertypes.ClusterWorkflowTemplateStore, wfDefaults *v1alpha1.Workflow) clusterwftmplpkg.ClusterWorkflowTemplateServiceServer {\n\tif cwftmplStore == nil {\n\t\tcwftmplStore = NewClientStore()\n\t}\n\treturn &Server{instanceID, cwftmplStore, wfDefaults}\n}\n\nfunc (cwts *Server) CreateClusterWorkflowTemplate(ctx context.Context, req *clusterwftmplpkg.ClusterWorkflowTemplateCreateRequest) (*v1alpha1.ClusterWorkflowTemplate, error) {\n\twfClient := auth.GetWfClient(ctx)\n\tif req.Template == nil {\n\t\treturn nil, serverutils.ToStatusError(fmt.Errorf(\"cluster workflow template was not found in the request body\"), codes.InvalidArgument)\n\t}\n\tcwts.instanceIDService.Label(req.Template)\n\tcreator.LabelCreator(ctx, req.Template)\n\tcwftmplGetter := cwts.cwftmplStore.Getter(ctx)\n\terr := validate.ClusterWorkflowTemplate(ctx, nil, cwftmplGetter, req.Template, cwts.wfDefaults, validate.Opts{})\n\tif err != nil {\n\t\treturn nil, serverutils.ToStatusError(err, codes.InvalidArgument)\n\t}\n\tres, err := wfClient.ArgoprojV1alpha1().ClusterWorkflowTemplates().Create(ctx, req.Template, v1.CreateOptions{})\n\tif err != nil {\n\t\treturn nil, serverutils.ToStatusError(err, codes.Internal)\n\t}\n\treturn res, nil\n}\n\nfunc (cwts *Server) GetClusterWorkflowTemplate(ctx context.Context, req *clusterwftmplpkg.ClusterWorkflowTemplateGetRequest) (*v1alpha1.ClusterWorkflowTemplate, error) {\n\tallowed, err := auth.CanI(ctx, \"get\", \"clusterworkflowtemplates\", \"\", req.Name)\n\tif err != nil {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/server/clusterworkflowtemplate/cluster_workflow_template_server.go#L21-L57","documentation":"CreateClusterWorkflowTemplate requires a ClusterWorkflowTemplate payload in the request; when req.Template is nil the server rejects the call with a gRPC InvalidArgument status. It is a request-shape guard before validation and labelling run.","triggerScenarios":"Calling the ClusterWorkflowTemplateService.Create RPC (or `argo cluster-template create`) with an empty body, a CreateRequest that omits `template`, a client SDK call where the template object was not assigned, or Lint mode misuse where only generateName metadata is sent.","commonSituations":"Hand-crafted gRPC/REST payloads against the grpc-gateway endpoint missing the `template` JSON field; SDK usage like `client.NewClusterWorkflowTemplateClient().Create(ctx, &clusterwftmplpkg.ClusterWorkflowTemplateCreateRequest{Namespace: ns})` without Template; JSON with a misspelled key (`templte`) silently yielding nil.","solutions":["Populate the request: pass `-f template.yaml` to `argo cluster-template create` or set `CreateRequest.Template` in the SDK.","Check the top-level JSON/YAML key is `template:` (not `clusterWorkflowTemplate:` or nested incorrectly).","Verify you use the cluster-template command, not the namespaced `argo template create`, for ClusterWorkflowTemplates.","When calling the HTTP gateway, ensure the body is `{\"template\": {...}}` and Content-Type is application/json.","Lint the file first with `argo cluster-template lint template.yaml` to confirm it parses into a template object."],"exampleFix":"// before\nreq := &clusterwftmplpkg.ClusterWorkflowTemplateCreateRequest{}\n// after\ntmpl, _ := utils.ParseClusterWorkflowTemplateYamlFile(\"cwft.yaml\")\nreq := &clusterwftmplpkg.ClusterWorkflowTemplateCreateRequest{Template: tmpl}","handlingStrategy":"validation","validationCode":"func validateCreateReq(req *clusterwftmplpkg.ClusterWorkflowTemplateCreateRequest) error {\n\tif req == nil || req.Template == nil {\n\t\treturn errors.New(\"request must include template\")\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"_, err := client.Create(ctx, req)\nif err != nil {\n\tif st, ok := status.FromError(err); ok && st.Code() == codes.InvalidArgument {\n\t\t// fix request: attach Template from file\n\t}\n\treturn err\n}","preventionTips":["Always pass -f <file> to argo cluster-template create","Construct requests via helper parsers (ParseClusterWorkflowTemplateYamlFile), never by hand","Lint with `argo cluster-template lint` before submitting","Use correct top-level JSON key `template` for gateway calls"],"tags":["grpc","api","request-validation","clusterworkflowtemplate"],"backgroundTag":"missing-request-body-template","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"}