{"record":{"id":"cc944bcee21f9ffc","repo":"cloudflare/cloudflared","slug":"cloudflared-tunnel-rule-expects-a-single-argument","errorCode":null,"errorMessage":"cloudflared tunnel rule expects a single argument, the URL to test","messagePattern":"cloudflared tunnel rule expects a single argument, the URL to test","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/tunnel/ingress_subcommands.go","lineNumber":123,"sourceCode":"\tif c.IsSet(ingressDataJSONFlagName) {\n\t\tingressJSON := c.String(ingressDataJSONFlagName)\n\t\tfmt.Println(\"Validating rules from cmdline flag --json\")\n\t\terr := json.Unmarshal([]byte(ingressJSON), &conf)\n\t\treturn conf, err\n\t}\n\tconf = config.GetConfiguration()\n\tif conf.Source() == \"\" {\n\t\treturn nil, errors.New(\"No configuration file was found. Please create one, or use the --config flag to specify its filepath. You can use the help command to learn more about configuration files\")\n\t}\n\tfmt.Println(\"Validating rules from\", conf.Source())\n\treturn conf, nil\n}\n\n// testURLCommand checks which ingress rule matches the given URL.\nfunc testURLCommand(c *cli.Context) error {\n\trequestArg := c.Args().First()\n\tif requestArg == \"\" {\n\t\treturn errors.New(\"cloudflared tunnel rule expects a single argument, the URL to test\")\n\t}\n\n\trequestURL, err := url.Parse(requestArg)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s is not a valid URL\", requestArg)\n\t}\n\tif requestURL.Hostname() == \"\" && requestURL.Scheme == \"\" {\n\t\treturn fmt.Errorf(\"%s doesn't have a hostname, consider adding a scheme\", requestArg)\n\t}\n\n\tconf := config.GetConfiguration()\n\tfmt.Println(\"Using rules from\", conf.Source())\n\ting, err := ingress.ParseIngress(conf)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Validation failed\")\n\t}\n\n\t_, i := ing.FindMatchingRule(requestURL.Hostname(), requestURL.Path)","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/tunnel/ingress_subcommands.go#L105-L141","documentation":"testURLCommand requires exactly one argument: the URL to test against ingress rules. `c.Args().First()` returning empty string means the user invoked `cloudflared tunnel rule` without a URL, so cloudflared throws this error before parsing.","triggerScenarios":"Running `cloudflared tunnel rule` with no argument, or with only flags (e.g. `--config ...`) and no positional URL.","commonSituations":"Copy-pasting the command from docs but omitting the URL argument; forgetting to quote URLs so the shell splits them.","solutions":["Supply the URL to test: `cloudflared tunnel rule https://example.com/path`.","Quote URLs containing special shell characters: `cloudflared tunnel rule 'https://example.com:8080/path?q=1'`.","Check `cloudflared tunnel rule --help` for expected usage."],"exampleFix":"// before\ncloudflared tunnel rule\n// after\ncloudflared tunnel rule https://example.com/","handlingStrategy":"validation","validationCode":"if [ -z \"$1\" ]; then echo \"usage: cloudflared tunnel rule <url>\" >&2; exit 1; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass exactly one URL argument to `tunnel rule`.","Quote URLs with special characters.","Wrap rule checks in helper scripts that assert argument presence."],"tags":["cli","ingress","missing-argument"],"backgroundTag":"missing-cli-argument","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}