Repository navigation
feat(keys): support auth-key node attributes - #112
Merged
jaxxstorm merged 3 commits intoNov 7, 2026
Merged
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The request model sends an explicit expirySeconds: 0 when --expiry is omitted, bypassing the contract’s absent-property default; add omitempty and test that the property is absent.
1 open issue
What changed in this PR
Adds custom device posture attributes to auth-key creation through tscli create key --node-attributes, using a local request model without upgrading the SDK.
Changes:
- Validates attribute names, types, and count before client initialization while preserving large integers.
- Adds payload, validation, permission-error, and default-omission tests.
- Refreshes the OpenAPI snapshot, coverage reports, and command documentation.
| File | Description |
|---|---|
tools/internal/coveragegaps/properties.go |
Uses the shared capability model for request coverage. |
tools/internal/coveragegaps/key_properties_test.go |
Checks node-attribute property coverage. |
test/cli/create_key_node_attributes_test.go |
Tests attribute serialization and existing flags. |
test/cli/create_key_node_attributes_error_test.go |
Tests permission-error reporting. |
test/cli/create_key_flags_integration_test.go |
Checks default omission of node attributes. |
pkg/contract/openapi/tailscale-v2-openapi.yaml |
Adds the upstream attribute schema and permission requirement. |
pkg/contract/openapi/snapshot-metadata.yaml |
Updates snapshot timestamp and checksum. |
pkg/apitype/key.go |
Defines local auth-key request and capability models. |
docs/commands/tscli_create_key.md |
Documents the flag, example, and caller permissions. |
coverage/property-coverage.yaml |
Registers attribute payload test evidence. |
coverage/coverage-gaps.md |
Refreshes the readable property coverage report. |
coverage/coverage-gaps.json |
Refreshes machine-readable property coverage. |
cmd/tscli/create/key/node_attributes.go |
Parses and validates attributes without numeric rounding. |
cmd/tscli/create/key/node_attributes_test.go |
Tests boundaries and validation before client initialization. |
cmd/tscli/create/key/cli.go |
Wires the flag into validation and authenticated requests. |
Review effort: Balanced
Make ExpirySeconds optional in CreateKeyRequest. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
jaxxstorm
deleted the
automation/tailscale-api-auth-key-node-attributes
branch
November 7, 2026 22:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
tscli create key --node-attributes '<JSON object>'for auth keys, serialized atcapabilities.devices.create.nodeAttributes.custom:names, at most 100 attributes, and string/integer-literal/boolean values before initializing the API client. Preserve large integers without float64 conversion and preserve existing capability flags, description, expiry, and default omission behavior.get key, andlist keys(including--all) through a local response model that retains SDK metadata. Keep the existing single-object/list-array output shapes.Upstream evidence and scope
Source: Tailscale's official API v2 OpenAPI schema,
KeyCapabilities.devices.create.nodeAttributesand thecreateKeyoperation description. Newly observed by the API watcher on November 7, 2026; this is an observation date, not a claimed release date. The changelog did not announce a corresponding new entry.The calling OAuth credential needs
devices:posture_attributesin addition toauth_keys. The command's--scopeflag does not grant permissions to its caller. This flag is rejected for OAuth-client and federated-credential creation. Numbers use JSON integer literals (not decimal/exponent notation).The successful POST
/tailnet/{tailnet}/keysand GET/tailnet/{tailnet}/keys/{keyId}responses referenceKey; the list response containskeys[]ofKey.Key.capabilitiesreferencesKeyCapabilities, so node attributes are part of these response contracts too. The confirmed SDK field-loss gap is fixed for auth-key creation/get/list, and these response properties are now covered rather than hidden behind default exclusions. Existing OAuth/federated creation requests remain unchanged; the schema limits device capabilities to auth keys.No SDK/dependency upgrade, real tailnet mutations, merges, releases, or deployments.
Verification
All passed locally:
go test ./...go -C tools test ./...go test -race ./cmd/tscli/create/key ./pkg/apitype ./pkg/output ./test/cligo build ./...andgo -C tools build ./...go vet ./...andgo -C tools vet ./...make coverage-gaps-check(zero uncovered operations/properties)make docs-generateandmake docs-checkgit diff --cached --checkObserved failing tests before implementation for the missing flag, validation, and property registry, then passing tests. Mock HTTP tests cover mixed types, large integers, exact nesting, existing flags/defaults, and actionable API permission failures; validation tests cover malformed input, namespace/type/count limits, and non-auth-key rejection. Baseline root tests also passed.
Response regressions were observed failing before each create/get/list fix, and a second failure exposed printer rounding of
9007199254740993. Passing mock regressions now verify mixed attribute types, exact large integers in JSON/YAML, preserved metadata/capability flags, list array shape andall=true, empty lists, malformed responses, and API permission errors. Model compatibility tests compare attribute-free responses with the pinned SDK. Numeric printer tests also cover nested arrays, decimal/exponent numbers, and integers larger than uint64. The response property registry test was red before registration, then green.One-shot self-review and added-line security scan completed: no findings. No independent human review claimed. Default branch and all open PRs rechecked before publishing; the existing dependency PR is unrelated.