{"record":{"id":"bb466ce1f603b023","repo":"argoproj/argo-workflows","slug":"failed-to-create-request-w","errorCode":null,"errorMessage":"failed to create request: %w","messagePattern":"failed to create request: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argo/commands/cp.go","lineNumber":128,"sourceCode":"\tcommand.Flags().StringVar(&nodeID, \"node-id\", \"\", \"id of node in workflow\")\n\tcommand.Flags().StringVar(&templateName, \"template-name\", \"\", \"name of template in workflow\")\n\tcommand.Flags().StringVar(&artifactName, \"artifact-name\", \"\", \"name of output artifact in workflow\")\n\tcommand.Flags().StringVar(&customPath, \"path\", \"{namespace}/{workflowName}/{nodeId}/outputs/{artifactName}\", \"use variables {workflowName}, {nodeId}, {templateName}, {artifactName}, and {namespace} to create a customized path to store the artifacts; example: {workflowName}/{templateName}/{artifactName}\")\n\treturn command\n}\n\nfunc newArtifactHTTPClient(opts apiclient.ArgoServerOpts) (*http.Client, error) {\n\ttlsConfig, err := tlsutil.GetClientTLSConfig(opts.ClientCert, opts.ClientKey, opts.CACert, opts.InsecureSkipVerify)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}}, nil\n}\n\nfunc getAndStoreArtifactData(ctx context.Context, namespace string, workflowName string, nodeID string, artifactName string, fileName string, customPath string, c *http.Client, argoServerOpts apiclient.ArgoServerOpts) error {\n\trequest, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf(\"%s/artifacts/%s/%s/%s/%s\", argoServerOpts.GetURL(), namespace, workflowName, nodeID, artifactName), nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create request: %w\", err)\n\t}\n\tauthString, err := client.GetAuthString(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\trequest.Header.Set(\"Authorization\", authString)\n\tresp, err := c.Do(request)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"request failed with: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"request failed %s\", resp.Status)\n\t}\n\tartifactFilePath := filepath.Join(customPath, fileName)\n\tfileWriter, err := os.Create(artifactFilePath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating file failed: %w\", err)","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/cp.go#L110-L146","documentation":"getAndStoreArtifactData builds the artifact download request with http.NewRequestWithContext using the argo server URL plus namespace/workflow/node/artifact path segments. This error wraps any failure from http.NewRequestWithContext, which in practice only fails if the constructed URL is malformed (unparseable host or path with illegal characters).","triggerScenarios":"argoServerOpts.GetURL() returns an empty or malformed URL (misconfigured ARGO_SERVER/URL), or workflow/node/artifact names interpolated into the path contain characters that make the URL invalid.","commonSituations":"ARGO_SERVER unset or set to a value without scheme/host; custom characters in workflow or artifact names; programmatic misuse of apiclient.ArgoServerOpts with a bad URL.","solutions":["Check the resolved server URL (ARGO_SERVER / ARGO_SECURE / port) — it must be a valid absolute http(s) URL.","Ensure workflow/node/artifact identifiers are standard Kubernetes names (lowercase alphanumerics, '-', '.').","Print or log argoServerOpts.GetURL() when running programmatically to inspect the constructed URL.","Retry with a clean environment (unset ARGO_SERVER and use port-forward + defaults) to isolate the bad value."],"exampleFix":"// before\nos.Setenv(\"ARGO_SERVER\", \"localhost:2746/path with space\")\n// after\nos.Setenv(\"ARGO_SERVER\", \"localhost:2746\")","handlingStrategy":"validation","validationCode":"// validate the server URL before issuing requests\nu, err := url.Parse(argoServerOpts.GetURL())\nif err != nil || u.Scheme == \"\" || u.Host == \"\" {\n  return fmt.Errorf(\"invalid argo server URL: %q\", argoServerOpts.GetURL())\n}","typeGuard":"func validServerURL(raw string) bool {\n  u, err := url.Parse(raw)\n  return err == nil && (u.Scheme == \"http\" || u.Scheme == \"https\") && u.Host != \"\"\n}","tryCatchPattern":"if strings.Contains(err.Error(), \"failed to create request\") {\n  return fmt.Errorf(\"check ARGO_SERVER / ArgoServerOpts.URL: %w\", err)\n}","preventionTips":["Set ARGO_SERVER to host:port (no path, no spaces) and confirm with `argo list`.","Sanitize workflow/artifact names passed programmatically into download URLs.","Validate ArgoServerOpts.URL in wrappers around the CLI."],"tags":["cli","http","url","configuration"],"backgroundTag":"invalid-url","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"}