argoproj/argo-workflows · error

InvalidArgument

InvalidArgument

Error message

cluster workflow template was not found in the request body

What it means

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.

Source

Thrown at server/clusterworkflowtemplate/cluster_workflow_template_server.go:39

)

type Server struct {
	instanceIDService instanceid.Service
	cwftmplStore      servertypes.ClusterWorkflowTemplateStore
	wfDefaults        *v1alpha1.Workflow
}

func NewClusterWorkflowTemplateServer(instanceID instanceid.Service, cwftmplStore servertypes.ClusterWorkflowTemplateStore, wfDefaults *v1alpha1.Workflow) clusterwftmplpkg.ClusterWorkflowTemplateServiceServer {
	if cwftmplStore == nil {
		cwftmplStore = NewClientStore()
	}
	return &Server{instanceID, cwftmplStore, wfDefaults}
}

func (cwts *Server) CreateClusterWorkflowTemplate(ctx context.Context, req *clusterwftmplpkg.ClusterWorkflowTemplateCreateRequest) (*v1alpha1.ClusterWorkflowTemplate, error) {
	wfClient := auth.GetWfClient(ctx)
	if req.Template == nil {
		return nil, serverutils.ToStatusError(fmt.Errorf("cluster workflow template was not found in the request body"), codes.InvalidArgument)
	}
	cwts.instanceIDService.Label(req.Template)
	creator.LabelCreator(ctx, req.Template)
	cwftmplGetter := cwts.cwftmplStore.Getter(ctx)
	err := validate.ClusterWorkflowTemplate(ctx, nil, cwftmplGetter, req.Template, cwts.wfDefaults, validate.Opts{})
	if err != nil {
		return nil, serverutils.ToStatusError(err, codes.InvalidArgument)
	}
	res, err := wfClient.ArgoprojV1alpha1().ClusterWorkflowTemplates().Create(ctx, req.Template, v1.CreateOptions{})
	if err != nil {
		return nil, serverutils.ToStatusError(err, codes.Internal)
	}
	return res, nil
}

func (cwts *Server) GetClusterWorkflowTemplate(ctx context.Context, req *clusterwftmplpkg.ClusterWorkflowTemplateGetRequest) (*v1alpha1.ClusterWorkflowTemplate, error) {
	allowed, err := auth.CanI(ctx, "get", "clusterworkflowtemplates", "", req.Name)
	if err != nil {

View on GitHub (pinned to 35bff19146)

Solutions

  1. Populate the request: pass `-f template.yaml` to `argo cluster-template create` or set `CreateRequest.Template` in the SDK.
  2. Check the top-level JSON/YAML key is `template:` (not `clusterWorkflowTemplate:` or nested incorrectly).
  3. Verify you use the cluster-template command, not the namespaced `argo template create`, for ClusterWorkflowTemplates.
  4. When calling the HTTP gateway, ensure the body is `{"template": {...}}` and Content-Type is application/json.
  5. Lint the file first with `argo cluster-template lint template.yaml` to confirm it parses into a template object.

Example fix

// before
req := &clusterwftmplpkg.ClusterWorkflowTemplateCreateRequest{}
// after
tmpl, _ := utils.ParseClusterWorkflowTemplateYamlFile("cwft.yaml")
req := &clusterwftmplpkg.ClusterWorkflowTemplateCreateRequest{Template: tmpl}
Defensive patterns

Strategy: validation

Validate before calling

func validateCreateReq(req *clusterwftmplpkg.ClusterWorkflowTemplateCreateRequest) error {
	if req == nil || req.Template == nil {
		return errors.New("request must include template")
	}
	return nil
}

Try / catch

_, err := client.Create(ctx, req)
if err != nil {
	if st, ok := status.FromError(err); ok && st.Code() == codes.InvalidArgument {
		// fix request: attach Template from file
	}
	return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03). Data as JSON: /api/errors/d6c79dd6af1f93f2. Report an issue: GitHub.