[Bug] -u --user argument is inconsistent, --identifier/--name unavailable (sometimes --user takes uint, sometimes string) #1040

Open
opened 2025-12-29 02:27:53 +01:00 by adam · 6 comments
Owner

Originally created by @tgrushka on GitHub (May 28, 2025).

Is this a support request?

  • This is not a support request

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Works as expected:

headscale nodes list -u myusername

Fails:

headscale preauthkeys list -u myusername
invalid argument "myusername" for "-u, --user" flag: strconv.ParseUint: parsing "myusername": invalid syntax

Also fails:

headscale users rename -u myusername
Error: unknown shorthand flag: 'u' in -u

But at least it accepts:

  -i, --identifier int    User identifier (ID) (default -1)
  -n, --name string       Username

Expected Behavior

Most commands require a -u / --user argument, naturally. Perhaps that should be changed to -i / -n so we can use either a number or name.

Having to look up the ID number of a user is an extra step when scripting, e.g.

# Step 1. Get user ID number
USER_ID=$(headscale users show -n {{ HEADSCALE_USER }} --output json | jq -r '.[0].id')
# Step 2. Get preauth keys so we can expire the old ones.
headscale preauthkeys list -u $USER_ID
headscale preauthkeys list -u myusername

should work just as well as

headscale nodes list -u myusername

Or, it should work like:

headscale users rename -n myusername

or

headscale users rename -i 1234

Perhaps the latter is the "new way" and it's in progress?

Steps To Reproduce

Try the above commands with a real username.

Environment

- OS: Debian GNU/Linux 12 (bookworm)
- Headscale version: 0.26.0
- Tailscale version: N/A, this is only related to headscale CLI commands

Runtime environment

  • Headscale is behind a (reverse) proxy
  • Headscale runs in a container

Debug information

This is not related to tailscale client at all. It's only related to the CLI command/argument structure. If more info needed, please let me know.

Originally created by @tgrushka on GitHub (May 28, 2025). ### Is this a support request? - [x] This is not a support request ### Is there an existing issue for this? - [x] I have searched the existing issues ### Current Behavior Works as expected: ``` headscale nodes list -u myusername ``` Fails: ``` headscale preauthkeys list -u myusername invalid argument "myusername" for "-u, --user" flag: strconv.ParseUint: parsing "myusername": invalid syntax ``` Also fails: ``` headscale users rename -u myusername Error: unknown shorthand flag: 'u' in -u ``` But at least it accepts: ``` -i, --identifier int User identifier (ID) (default -1) -n, --name string Username ``` ### Expected Behavior Most commands require a `-u` / `--user` argument, naturally. Perhaps that should be changed to `-i` / `-n` so we can use either a number or name. Having to look up the ID number of a user is an extra step when scripting, e.g. ``` # Step 1. Get user ID number USER_ID=$(headscale users show -n {{ HEADSCALE_USER }} --output json | jq -r '.[0].id') # Step 2. Get preauth keys so we can expire the old ones. headscale preauthkeys list -u $USER_ID ``` ``` headscale preauthkeys list -u myusername ``` should work just as well as ``` headscale nodes list -u myusername ``` Or, it should work like: ``` headscale users rename -n myusername ``` or ``` headscale users rename -i 1234 ``` Perhaps the latter is the "new way" and it's in progress? ### Steps To Reproduce Try the above commands with a real username. ### Environment ```markdown - OS: Debian GNU/Linux 12 (bookworm) - Headscale version: 0.26.0 - Tailscale version: N/A, this is only related to headscale CLI commands ``` ### Runtime environment - [ ] Headscale is behind a (reverse) proxy - [ ] Headscale runs in a container ### Debug information This is not related to `tailscale` client at all. It's only related to the CLI command/argument structure. If more info needed, please let me know.
adam added the bug label 2025-12-29 02:27:53 +01:00
Author
Owner

@kradalby commented on GitHub (May 28, 2025):

Yes, its a mess, we are aware, we would appreciate if you could help contribute to improving it! Thanks.

@kradalby commented on GitHub (May 28, 2025): Yes, its a mess, we are aware, we would appreciate if you could help contribute to improving it! Thanks.
Author
Owner

@tevinflores commented on GitHub (May 29, 2025):

@kradalby I can give it a shot. If no one has started it

@tevinflores commented on GitHub (May 29, 2025): @kradalby I can give it a shot. If no one has started it
Author
Owner

@kradalby commented on GitHub (May 29, 2025):

Yes sure, I think a lot of the code is similar, and can probably be more reused.

This effort would probably benefit from some planning, outline how it currently is and where we want it to go.

@kradalby commented on GitHub (May 29, 2025): Yes sure, I think a lot of the code is similar, and can probably be more reused. This effort would probably benefit from some planning, outline how it currently is and where we want it to go.
Author
Owner

@bluepuma77 commented on GitHub (Jul 2, 2025):

Documentation is wrong, too (doc). Making it hard for new users.

Generate a key using the command line:

docker exec -it headscale \
  headscale preauthkeys create --user myfirstuser --reusable --expiration 24h
Error: invalid argument "myfirstuser" for "-u, --user" flag: strconv.ParseUint: parsing "myfirstuser": invalid syntax

Why would a user (created by username) suddenly be represented by an integer? Which isn't even logged when creating the user. So it needs a dedicated lookup and you need to remember the id. Makes no sense to me.

Interestingly this works, which is shown by the register URL:

headscale nodes register --user USERNAME --key NV4RcnRP7vaONKmTB7V12345
@bluepuma77 commented on GitHub (Jul 2, 2025): Documentation is wrong, too ([doc](https://headscale.net/stable/setup/install/container/#register-a-machine-normal-login)). Making it hard for new users. >Generate a key using the command line: >``` >docker exec -it headscale \ > headscale preauthkeys create --user myfirstuser --reusable --expiration 24h >``` ``` Error: invalid argument "myfirstuser" for "-u, --user" flag: strconv.ParseUint: parsing "myfirstuser": invalid syntax ``` Why would a user (created by username) suddenly be represented by an integer? Which isn't even logged when creating the user. So it needs a dedicated lookup and you need to remember the id. Makes no sense to me. Interestingly this works, which is shown by the register URL: ``` headscale nodes register --user USERNAME --key NV4RcnRP7vaONKmTB7V12345 ```
Author
Owner

@tevinflores commented on GitHub (Nov 9, 2025):

@kradalby I will update my current branch for this bug since I was already working on it a while back but not it's outdated.

@tevinflores commented on GitHub (Nov 9, 2025): @kradalby I will update my current branch for this bug since I was already working on it a while back but not it's outdated.
Author
Owner

@Zocker1999NET commented on GitHub (Dec 13, 2025):

Generate a key using the command line:

docker exec -it headscale \
  headscale preauthkeys create --user myfirstuser --reusable --expiration 24h

I want to make aware that this has worked in earlier versions of headscale (at least in 0.25.1 because that is what its NixOS test at that time used, see this line).
And actually I would be interested to know why this was changed 🤔

@Zocker1999NET commented on GitHub (Dec 13, 2025): > Generate a key using the command line: > ``` > docker exec -it headscale \ > headscale preauthkeys create --user myfirstuser --reusable --expiration 24h > ``` I want to make aware that this has worked in earlier versions of headscale (at least in 0.25.1 because that is what its NixOS test at that time used, see [this line](https://github.com/NixOS/nixpkgs/blob/da2b89022cf3da1045c8cc9bb5c816de22fdd788/nixos/tests/headscale.nix#L81)). And actually I would be interested to know why this was changed 🤔
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#1040