tpagectl: offline commands fail when server config is invalid #582

Closed
opened 2026-08-07 06:35:46 +00:00 by the.auditor · 1 comment
Owner

tpagectl version runs the root command's Before hook, which loads the config and constructs the HTTP client (newClient in cmd/tpagectl/main.go). The version command never talks to the daemon, yet a misconfigured or invalid --server URL (or broken config file) would make version fail before its action runs.

Suggested fix: skip client construction for commands that don't need it (e.g. make version, --help, and completion bypass the client in the Before hook), or defer client construction to the commands that require it.

Ref: PR #581

`tpagectl version` runs the root command's `Before` hook, which loads the config and constructs the HTTP client (`newClient` in `cmd/tpagectl/main.go`). The `version` command never talks to the daemon, yet a misconfigured or invalid `--server` URL (or broken config file) would make `version` fail before its action runs. Suggested fix: skip client construction for commands that don't need it (e.g. make `version`, `--help`, and `completion` bypass the client in the Before hook), or defer client construction to the commands that require it. Ref: PR #581
Owner

Fixed in #634: offline commands (version, help, completion, docs, any --examples) skip config/client bootstrap via offlineCommand, so they succeed even with a broken config or unusable --server.

Fixed in #634: offline commands (`version`, `help`, `completion`, `docs`, any `--examples`) skip config/client bootstrap via `offlineCommand`, so they succeed even with a broken config or unusable `--server`.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/thwap-pagesd#582
No description provided.