tailscale/tailscale · warning
error: missing service name argument
Error message
error: missing service name argument
What it means
`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.
Source
Thrown at cmd/tailscale/cli/serve_v2.go:650
}
sc, err := e.lc.GetServeConfig(ctx)
if err != nil {
return fmt.Errorf("error getting serve config: %w", err)
}
if _, ok := sc.Services[svc]; !ok {
log.Printf("service %s not found in serve config, nothing to clear", svc)
return nil
}
delete(sc.Services, svc)
if err := e.removeServiceFromPrefs(ctx, svc); err != nil {
return fmt.Errorf("error removing service %s from prefs: %w", svc, err)
}
return e.lc.SetServeConfig(ctx, sc)
}
func (e *serveEnv) runServeAdvertise(ctx context.Context, args []string) error {
if len(args) == 0 {
return errors.New("error: missing service name argument")
}
if len(args) != 1 {
fmt.Fprintf(Stderr, "error: invalid number of arguments\n\n")
return errHelp
}
svc := tailcfg.ServiceName(args[0])
if err := svc.Validate(); err != nil {
return fmt.Errorf("invalid service name: %w", err)
}
return e.addServiceToPrefs(ctx, svc)
}
func (e *serveEnv) runServeGetConfig(ctx context.Context, args []string) (err error) {
forSingleService := e.service.Validate() == nil
sc, err := e.lc.GetServeConfig(ctx)
if err != nil {
return err
}View on GitHub (pinned to cfe32b8be6)
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)
Example fix
// before $ tailscale serve advertise error: missing service name argument // after $ tailscale serve advertise svc:myapp
Defensive patterns
Strategy: validation
Validate before calling
svc := os.Getenv("SVC")
if svc == "" {
log.Fatal("serve advertise requires a service name (svc:<name>)")
}
if err := tailcfg.ServiceName(svc).Validate(); err != nil {
log.Fatalf("invalid service name: %v", err)
} Try / catch
if err := exec.Command("tailscale", "serve", "advertise", svc).Run(); err != nil {
if strings.Contains(err.Error(), "missing service name argument") {
// caller bug: empty variable reached the CLI
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- must specify filename
- unable to serve; text cannot be an empty string
- unexpected arguments
- expected at least one argument
- expected at least one argument after method
AI-assisted analysis of tailscale/tailscale@cfe32b8be6 (2026-08-15).
Data as JSON: /api/errors/5c36ce2fa02521b1.
Report an issue: GitHub.