Skip to content

Defer API key check so --help and --tree work without a key - #12

Merged
ClayMav merged 1 commit into
add-api-key-link-on-missing-keyfrom
fix/help-tree-without-api-key
Apr 7, 2026
Merged

Defer API key check so --help and --tree work without a key#12
ClayMav merged 1 commit into
add-api-key-link-on-missing-keyfrom
fix/help-tree-without-api-key

Conversation

@ClayMav

@ClayMav ClayMav commented Apr 2, 2026

Copy link
Copy Markdown
Member

Summary

  • config.Load() no longer fails when WHEROBOTS_API_KEY is unset, allowing informational commands (--help, --tree, version, upgrade) to run without a key
  • Adds Config.RequireAPIKey() method that produces the same user-friendly error with API key creation link, now called lazily by executor.BuildRequest() right before making an actual HTTP request
  • Updates tests to match the new deferred validation behavior

Fixes BUG-1870: --help and --tree require an api key

Test plan

  • All existing tests pass (go test ./...)
  • Run wherobots --help without WHEROBOTS_API_KEY set — should display help
  • Run wherobots --tree without WHEROBOTS_API_KEY set — should display command tree
  • Run wherobots api <command> without key — should show the API key error with creation link

config.Load() no longer fails when WHEROBOTS_API_KEY is unset. Instead,
the check moves to Config.RequireAPIKey(), called by executor.BuildRequest()
right before an actual HTTP request is made. This lets purely informational
commands (--help, --tree, version, upgrade) run without a key.

Fixes BUG-1870
@ClayMav
ClayMav changed the base branch from main to add-api-key-link-on-missing-key April 2, 2026 16:50
@ClayMav
ClayMav marked this pull request as ready for review April 2, 2026 16:57
@ClayMav
ClayMav requested review from a team and peterfoldes and removed request for a team April 4, 2026 03:36
@ClayMav
ClayMav merged commit 58888d5 into add-api-key-link-on-missing-key Apr 7, 2026
1 check passed
@ClayMav
ClayMav deleted the fix/help-tree-without-api-key branch April 7, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant