fix: honor -v verbosity for HTTP logging in all commands#207
Open
scotwells wants to merge 3 commits into
Open
Conversation
The -v flag dumped HTTP requests only for kubectl-backed commands, because client-go wraps their transport with its debug round tripper. Commands that use bare net/http (e.g. plugin search fetching the index) showed nothing at any verbosity. Wrap the default transport once in the root PersistentPreRunE so -v 6+ dumps requests for every command. DebugWrappers is a no-op below -v 6. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A GitHub token in the environment (GITHUB_TOKEN or DATUMCTL_GITHUB_TOKEN) is attached to the plugin index request, but the public index host rejects unexpected Bearer tokens with a 404, producing a confusing "HTTP 404" error with no indication of the cause. Return a typed IndexFetchError that records the status and which env var the token came from, and surface a hint on 401/403/404 telling the user a token is being sent and to unset it. Wired into search, install, and upgrade. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
datumctlaccepts the standard-vverbosity flag, and users reasonably expect-v 6to dump HTTP traffic so they can debug connectivity, auth, and proxy issues. Today that only works for the kubectl-backed commands (get,apply, etc.) because client-go wraps their transport with its debug round tripper. Commands that talk to other services over barenet/http— for exampleplugin search, which fetches the plugin index — print nothing at any verbosity, which is confusing when you're trying to figure out why a request is slow or failing.This wraps the default HTTP transport once during root command setup, so
-vnow dumps requests consistently across every command, not just the Kubernetes-facing ones.Verbosity levels match the behavior users already know from the kubectl-backed commands:
-v 6— request URL and timing-v 7— adds request headers-v 8/-v 9— adds response headers, bodies, and curl-equivalent outputThe wrapper is a no-op below
-v 6, so normal runs are unaffected and pay no cost.Test plan
datumctl plugin search(no flag) — output unchanged, no debug noisedatumctl plugin search -v 6— logs the indexGETURL + timingdatumctl plugin search -v 7— additionally logs request headersgo build ./...,go vet, andgo test ./internal/...pass