Skip to content

docs(api-key): correct the --expires-at help text - #1164

Merged
dangrondahl merged 1 commit into
mainfrom
docs/api-key-expiry-help
Sep 11, 2026
Merged

dangrondahl merged 1 commit into
mainfrom
docs/api-key-expiry-help

Conversation

@dangrondahl

Copy link
Copy Markdown
Contributor

kosli create api-key --help told users that --expires-at "Defaults to no expiry", which is no longer true — the API does not issue non-expiring keys. Omitting expires_at gives the key the maximum allowed lifetime, and a date beyond that maximum is capped to it.

The empty flag default is unchanged and correct: not sending the field is what lets the API own the expiry policy, the same way --grace-period-hours already works. Duplicating the maximum client-side would only drift when the API changes it.

  • Split the shared apiKeyExpiresAtFlag constant in two — create and rotate genuinely default differently: create falls back to the maximum lifetime, rotate keeps the rotated key's current expiry.
  • Added a paragraph to the create api-key long description covering expiry and capping.
  • Dropped "server-side"/"server-managed" from the grace-period help text, which described where the value comes from rather than what the user gets.

No behaviour change — help text only.

Checklist

The help text claimed --expires-at "Defaults to no expiry", but the API no
longer issues non-expiring keys: omitting expires_at gives the key the
maximum allowed lifetime, and a later date is capped to that maximum.

Split the shared flag constant in two, since create and rotate default
differently: create falls back to the maximum lifetime, rotate keeps the
rotated key's current expiry. The empty flag default stays as it is — not
sending the field is what lets the API own the policy.

Also drop "server-side"/"server-managed" from the grace-period help, which
describes where the value comes from rather than what the user gets.
@github-actions github-actions Bot added go Pull requests that update go code docs labels Sep 11, 2026
@claude

claude Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Claude finished @dangrondahl's task in 3m 9s —— View job


Review: docs(api-key): correct the --expires-at help text

  • Read PR diff
  • Static analysis (go build ./..., go vet ./..., go mod tidy + git diff --exit-code go.mod go.sum) — all clean
  • Review changed files, check for stale golden/doc artifacts
  • Post review (4 inline comments)

Static analysis

Check Result
go build ./...
go vet ./...
go mod tidy (no go.mod/go.sum drift)

No golden files or committed docs reference the old strings — make docs writes to client_reference/ (not committed), and cmd/kosli/testdata/empty-flag-audit-coverage.json records flag types only, so nothing needs regenerating. Grep confirms no remaining Defaults to no expiry / server-side value / server-managed occurrences.

I couldn't run ./kosli create api-key --help or the integration suite in this sandbox (command execution restricted / tests need the docker-compose server), so the rendered ^…^ → backtick output is unverified — though it follows the same convention as every other long description in the package.

Findings

1. createApiKey.go:19-20 — the new claim contradicts this package's own rendering layer. "Every API key expires" sits next to optionalTimestamp, which maps expires_at == 0 to N/A and documents it as "a zero value meaning 'never'/'not set'" (cmd/kosli/apiKey.go:133-134), plus two tests asserting // expires_at of 0 means "no expiry" (cmd/kosli/apiKey_test.go:40, :73). If the API can't return 0 any more those comments are stale; if it still can (legacy keys), the help overstates. Either way it belongs in this docs pass. Details inline.

2. root.go:158 — one unverifiable claim replaced by another. The CLI just omits expires_at on rotate (rotateApiKey.go:100-106), so "Defaults to the rotated key's current expiry" is purely a statement about server behaviour. Worth confirming against the OpenAPI spec that rotation carries the old expiry forward rather than granting a fresh maximum — nothing in this repo will catch it if it drifts.

3. root.go:157 — wording nit (suggestion inline): which also caps later dates has a distant antecedent, and capping isn't actually conditional on the flag being unset.

4. rotateApiKey.go:20 — non-blocking: "has a standard length" is vaguer than the "server-managed" it replaced; it names neither the length nor where to find it.

What's good

  • Splitting apiKeyExpiresAtFlag into per-command constants is the right fix, not a workaround — the two commands genuinely have different defaults, and the shared constant was structurally incapable of being accurate for both.
  • Resisting the urge to hardcode the maximum lifetime client-side is the correct call, and consistent with how --grace-period-hours already defers to the API.
  • Keeping the empty flag default unchanged means zero behaviour risk; the PR description is explicit about that and about the reasoning.
  • The long description carries the detail that doesn't fit in a flag usage line — right split between the two surfaces.

Nothing here blocks merge; #1 is the one I'd resolve before shipping, since it's the same class of drift this PR exists to fix.
• branch docs/api-key-expiry-help

Comment thread cmd/kosli/root.go
Comment thread cmd/kosli/root.go
Comment thread cmd/kosli/createApiKey.go
Comment thread cmd/kosli/rotateApiKey.go
@dangrondahl
dangrondahl enabled auto-merge (squash) September 11, 2026 10:21
@dangrondahl
dangrondahl merged commit 54ea249 into main Sep 11, 2026
21 checks passed
@dangrondahl
dangrondahl deleted the docs/api-key-expiry-help branch September 11, 2026 10:23
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
kosli-cli 2.40.1

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre># Improvements
- Updated flag descriptions for `--expires-at` on `create api-key` and `rotate api-key` to clarify expiry behaviour (keys always expire; unset defaults to maximum allowed lifetime; dates beyond the maximum are capped).
- Updated `--grace-period-hours` flag description to clarify it defaults to the standard server-side grace period.
- Updated long descriptions for `create api-key` and `rotate api-key` to reflect expiry and grace period behaviour.

<!-- Release notes generated using configuration in .github/release.yml at v2.40.1 -->

## What's Changed
* docs(api-key): correct the --expires-at help text by @dangrondahl in kosli-dev/cli#1164


**Full Changelog**: kosli-dev/cli@v2.40.0...v2.40.1

</pre>
  <p>View the full release notes at <a href="https://github.com/kosli-dev/cli/releases/tag/v2.40.1">https://github.com/kosli-dev/cli/releases/tag/v2.40.1</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!19978
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants