Skip to content

feat: add global --verbose flag for HTTP debugging#370

Open
Aditya200247 wants to merge 4 commits into
microcks:masterfrom
Aditya200247:feat/verbose-logging
Open

feat: add global --verbose flag for HTTP debugging#370
Aditya200247 wants to merge 4 commits into
microcks:masterfrom
Aditya200247:feat/verbose-logging

Conversation

@Aditya200247
Copy link
Copy Markdown

go test -v ./pkg/connectors
=== RUN TestDownloadArtifactReturnsResponseBody
--- PASS: TestDownloadArtifactReturnsResponseBody (0.00s)
=== RUN TestLoggingTransportSilentWhenVerboseFalse
--- PASS: TestLoggingTransportSilentWhenVerboseFalse (0.00s)
=== RUN TestLoggingTransportRedactsAuth
--- PASS: TestLoggingTransportRedactsAuth (0.00s)
PASS
ok github.com/microcks/microcks-cli/pkg/connectors 1.298s


go test -v ./cmd
=== RUN TestImportDirectory
=== RUN TestImportDirectory/successful_import_of_all_files
--- PASS: TestImportDirectory/successful_import_of_all_files (0.00s)
=== RUN TestImportDirectory/partial_failure
--- PASS: TestImportDirectory/partial_failure (0.00s)
=== RUN TestImportDirectory/recursive_scan
--- PASS: TestImportDirectory/recursive_scan (0.00s)
=== RUN TestImportDirectory/pattern_filtering
--- PASS: TestImportDirectory/pattern_filtering (0.00s)
--- PASS: TestImportDirectory (0.00s)
=== RUN TestValidateDirectory
--- PASS: TestValidateDirectory (0.00s)
=== RUN TestFindSpecificationFilesWithFS
--- PASS: TestFindSpecificationFilesWithFS (0.00s)
=== RUN TestDetectFileTypeWithLogic
--- PASS: TestDetectFileTypeWithLogic (0.00s)
=== RUN TestNewImportDirCommand
--- PASS: TestNewImportDirCommand (0.00s)
=== RUN TestImportResult
--- PASS: TestImportResult (0.00s)

--- FAIL: TestDeleteContext (0.00s) ← pre-existing upstream failure (unrelated to this PR)
open ./testdata/local.config: The system cannot find the path specified.

Description

Added a global -v / --verbose persistent flag to the root command to help users debug local connection issues.

Implemented a custom RoundTripper for the HTTP client that logs the request method, target URL, and response status to stderr.

Added security masking to ensure sensitive headers (specifically the Authorization header) are redacted and not printed to the console.

Related issue(s)

resolved #347

@github-actions
Copy link
Copy Markdown

👋 @Aditya200247

Welcome to the Microcks community! 💖

Thanks and congrats 🎉 for opening your first pull request here! Be sure to follow the pull request template or please update it accordingly.

Hope you have a great time there!

@Harsh4902
Copy link
Copy Markdown
Member

@Aditya200247 Can you please sign-off your commits? It's mendatory to sign-off commits while contributing to CNCF projects.

The old approach used a config.Verbose global and scattered
httputil.DumpRequestOut/DumpResponse calls across every method.
Replace it with a small loggingTransport that wraps the HTTP
client's RoundTripper once at construction time.

- Logs >> METHOD URL and each request header to stderr
- Redacts the Authorization header value
- Logs << STATUS after each response
- Removes the Verbose global and DumpRequestIfRequired /
  DumpResponseIfRequired helpers from pkg/config

Signed-off-by: Aditya <thakuradityakumar17@gmail.com>
Also remove the now-dead config.Verbose assignments from all
command Run functions - the flag value flows through
ClientOptions.Verbose directly into the HTTP client transport.

Signed-off-by: Aditya <thakuradityakumar17@gmail.com>
- Add verbose bool field to loggingTransport; RoundTrip is a no-op
  when verbose is false so the transport is always safe to install
- Add verbose param to NewMicrocksClient and NewKeycloakClient so
  the direct-auth code path (--microcksURL + --keycloakClientId)
  also logs when -v is passed
- Pass c.Verbose into the internal keycloak client used for token
  refresh so logging is consistent across the whole session
- Remove the local --verbose flag from import-dir (it conflicted
  with the root persistent flag); globalClientOpts.Verbose now
  drives both HTTP logging and the file-listing output
- Fix TestLoggingTransportSilentWhenVerboseFalse: read stderr
  before closing the pipe and assert zero bytes written
- Drop deprecated filepath.HasPrefix in importDir_test.go
- Remove the benchmark that was noise for this PR

Signed-off-by: Aditya <thakuradityakumar17@gmail.com>
- Remove dead ImportError type from importDir.go
- Add direct-auth path (--microcksURL + keycloak flags) to import-dir
  so it matches the other commands (import, test, import-url)
- Redirect verbose diagnostic output to stderr per issue spec
- Fix silent fmt.Errorf in executor.go (was swallowing the error)
  replaced with fmt.Fprintf(os.Stderr, ...)

Signed-off-by: Aditya <thakuradityakumar17@gmail.com>
@Aditya200247 Aditya200247 force-pushed the feat/verbose-logging branch from 563459b to 775349b Compare May 12, 2026 06:12
@Aditya200247
Copy link
Copy Markdown
Author

Hey @Harsh4902 ,
I have updated the PR and added sign-offs to my commits let me know if everything looks good now or if there are any other changes you'd like me to make.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a --verbose flag to help debug local connection issues

2 participants