{"record":{"id":"5c36ce2fa02521b1","repo":"tailscale/tailscale","slug":"error-missing-service-name-argument","errorCode":null,"errorMessage":"error: missing service name argument","messagePattern":"error: missing service name argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/tailscale/cli/serve_v2.go","lineNumber":650,"sourceCode":"\t}\n\tsc, err := e.lc.GetServeConfig(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error getting serve config: %w\", err)\n\t}\n\tif _, ok := sc.Services[svc]; !ok {\n\t\tlog.Printf(\"service %s not found in serve config, nothing to clear\", svc)\n\t\treturn nil\n\t}\n\tdelete(sc.Services, svc)\n\tif err := e.removeServiceFromPrefs(ctx, svc); err != nil {\n\t\treturn fmt.Errorf(\"error removing service %s from prefs: %w\", svc, err)\n\t}\n\treturn e.lc.SetServeConfig(ctx, sc)\n}\n\nfunc (e *serveEnv) runServeAdvertise(ctx context.Context, args []string) error {\n\tif len(args) == 0 {\n\t\treturn errors.New(\"error: missing service name argument\")\n\t}\n\tif len(args) != 1 {\n\t\tfmt.Fprintf(Stderr, \"error: invalid number of arguments\\n\\n\")\n\t\treturn errHelp\n\t}\n\tsvc := tailcfg.ServiceName(args[0])\n\tif err := svc.Validate(); err != nil {\n\t\treturn fmt.Errorf(\"invalid service name: %w\", err)\n\t}\n\treturn e.addServiceToPrefs(ctx, svc)\n}\n\nfunc (e *serveEnv) runServeGetConfig(ctx context.Context, args []string) (err error) {\n\tforSingleService := e.service.Validate() == nil\n\tsc, err := e.lc.GetServeConfig(ctx)\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":632,"sourceCodeEnd":668,"githubUrl":"https://github.com/tailscale/tailscale/blob/cfe32b8be6a33f8e24fbc369cbfbf7c729d9e042/cmd/tailscale/cli/serve_v2.go#L632-L668","documentation":"`tailscale serve advertise` requires exactly one argument: the service name to advertise. runServeAdvertise returns this error when args is empty, before any name validation or preference write happens. Nothing is mutated; the command simply refuses to guess which service to advertise.","triggerScenarios":"Calling `tailscale serve advertise` with zero arguments (len(args) == 0 in runServeAdvertise). Note: passing 2+ args produces a different error (invalid number of arguments + help); this exact message is only the zero-arg case.","commonSituations":"Scripts or automation invoking `serve advertise` with an unset/empty shell variable; users expecting the command to advertise all configured services or to prompt interactively.","solutions":["Pass a valid service name: `tailscale serve advertise svc:myapp`","If the name comes from a variable, check it is non-empty before invoking (e.g. `: \"${SVC:?service name required}\"`)","Confirm the exact spelling with `tailscale serve status`; names must pass svc.Validate() (svc: prefix)"],"exampleFix":"// before\n$ tailscale serve advertise\nerror: missing service name argument\n\n// after\n$ tailscale serve advertise svc:myapp","handlingStrategy":"validation","validationCode":"svc := os.Getenv(\"SVC\")\nif svc == \"\" {\n\tlog.Fatal(\"serve advertise requires a service name (svc:<name>)\")\n}\nif err := tailcfg.ServiceName(svc).Validate(); err != nil {\n\tlog.Fatalf(\"invalid service name: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := exec.Command(\"tailscale\", \"serve\", \"advertise\", svc).Run(); err != nil {\n\tif strings.Contains(err.Error(), \"missing service name argument\") {\n\t\t// caller bug: empty variable reached the CLI\n\t}\n}","preventionTips":["Fail fast on empty variables: `: \"${SVC:?required}\"`","Validate svc: names with tailcfg.ServiceName.Validate() before shelling out","Pin the exact subcommand syntax in scripts and lint for it"],"tags":["tailscale","serve","cli","argument-validation"],"backgroundTag":null,"analyzedSha":"cfe32b8be6a33f8e24fbc369cbfbf7c729d9e042","analyzedAt":"2026-08-15T19:58:31.583Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}