[Bug] headscale preauthkeys list -o json missing fields present in yaml: "reusable", "ephemeral" #926

Closed
opened 2025-12-29 02:26:15 +01:00 by adam · 3 comments
Owner

Originally created by @ringerc on GitHub (Jan 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

JSON and json-line output is missing reusable and ephemeral keys present in YAML output:

headscale preauthkeys list --user controlplane -o json | jq '[.[]|del(.user,.key,.expiration,.created_at,.acl_tags)]'

[
  {
    "id": "1",
    "used": true
  },
  {
    "id": "135",
    "used": true
  }
]

vs headscale preauthkeys list --user controlplane -o yaml | yq '[.[]|del(.user,.key,.expiration,.createdat,.acltags)]'

- id: "1"
  reusable: false
  ephemeral: false
  used: true
- id: "135"
  reusable: false
  ephemeral: false
  used: true

Expected Behavior

The json output should have values for .reusable and .ephemeral

Steps To Reproduce

create a headscale preauthkey for user $USERNAME and run headscale preauthkeys list --user "$USERNAME" -o json | jq '[.[]|del(.user,.key,.expiration,.created_at,.acl_tags)]

Compare to output of headscale preauthkeys list --user "$USERNAME" -o yaml | yq '[.[]|del(.user,.key,.expiration,.createdat,.acltags)]'

Environment

* headscale version: v0.24.0
* OS: Debian bookworm (google container distroless)
* base container: `docker.io/headscale/headscale:v0.24.0-debug`

Runtime environment

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

Anything else?

This looks like it might be a regression because way back in https://github.com/juanfont/headscale/issues/154 the output shows these keys output, but they're not present now.

It doesn't appear to be fixed in https://github.com/juanfont/headscale/releases/tag/v0.24.1 which is the latest since what I tested on

I find this difficult to explain given that the code seems to use a common path and marshal/unmarshal from the same structs for both outputs, but presumably I'm missing something.

Originally created by @ringerc on GitHub (Jan 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 JSON and `json-line` output is missing `reusable` and `ephemeral` keys present in YAML output: `headscale preauthkeys list --user controlplane -o json | jq '[.[]|del(.user,.key,.expiration,.created_at,.acl_tags)]'` ```json [ { "id": "1", "used": true }, { "id": "135", "used": true } ] ``` vs `headscale preauthkeys list --user controlplane -o yaml | yq '[.[]|del(.user,.key,.expiration,.createdat,.acltags)]' ` ```yaml - id: "1" reusable: false ephemeral: false used: true - id: "135" reusable: false ephemeral: false used: true ``` ### Expected Behavior The json output should have values for `.reusable` and `.ephemeral` ### Steps To Reproduce create a headscale preauthkey for user `$USERNAME` and run `headscale preauthkeys list --user "$USERNAME" -o json | jq '[.[]|del(.user,.key,.expiration,.created_at,.acl_tags)]` Compare to output of `headscale preauthkeys list --user "$USERNAME" -o yaml | yq '[.[]|del(.user,.key,.expiration,.createdat,.acltags)]'` ### Environment ```markdown * headscale version: v0.24.0 * OS: Debian bookworm (google container distroless) * base container: `docker.io/headscale/headscale:v0.24.0-debug` ``` ### Runtime environment - [ ] Headscale is behind a (reverse) proxy - [x] Headscale runs in a container ### Anything else? This looks like it might be a regression because way back in https://github.com/juanfont/headscale/issues/154 the output shows these keys output, but they're not present now. It doesn't appear to be fixed in https://github.com/juanfont/headscale/releases/tag/v0.24.1 which is the latest since what I tested on I find this difficult to explain given that the code seems to use a common path and marshal/unmarshal from the same structs for both outputs, but presumably I'm missing something.
adam added the bug label 2025-12-29 02:26:15 +01:00
adam closed this issue 2025-12-29 02:26:15 +01:00
Author
Owner

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

Can you try to do the output when you have a key set to ephemeral or reusable ? I wonder if it is omitted because the value is empty. Because Go treats false as default, it is also treated as empty and probably omitted.

@kradalby commented on GitHub (Jan 28, 2025): Can you try to do the output when you have a key set to `ephemeral` or `reusable` ? I wonder if it is omitted because the value is empty. Because Go treats false as default, it is also treated as empty and probably omitted.
Author
Owner

@ringerc commented on GitHub (Jan 28, 2025):

@kradalby That's a logical explanation, if confusing in usability terms. It would help explain how the differing output occurs despite the apparently common code paths.

That would explain why used is present - it's true, so it's non-default.

I'll test and check back.

@ringerc commented on GitHub (Jan 28, 2025): @kradalby That's a logical explanation, if confusing in usability terms. It would help explain how the differing output occurs despite the apparently common code paths. That would explain why `used` is present - it's true, so it's non-default. I'll test and check back.
Author
Owner

@ringerc commented on GitHub (Jan 28, 2025):

Confirmed

headscale preauthkey list -u REDACTED -o json
[
	{
		"user": "REDACTED",
		"id": "235",
		"key": "REDACTED",
		"reusable": true,
		"used": true,
		"expiration": {
			"seconds": 1769610894,
			"nanos": 654163208
		},
		"created_at": {
			"seconds": 1738074894,
			"nanos": 656921412
		},
		"acl_tags": ["REDACTED"]
	}
]

so I'll close this, as it's not a bug, but hopefully it'll help the next confused person. It's IMO a usability issue, but not a bug.

@ringerc commented on GitHub (Jan 28, 2025): Confirmed ``` headscale preauthkey list -u REDACTED -o json [ { "user": "REDACTED", "id": "235", "key": "REDACTED", "reusable": true, "used": true, "expiration": { "seconds": 1769610894, "nanos": 654163208 }, "created_at": { "seconds": 1738074894, "nanos": 656921412 }, "acl_tags": ["REDACTED"] } ] ``` so I'll close this, as it's not a bug, but hopefully it'll help the next confused person. It's IMO a usability issue, but not a bug.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#926