[log] Add debug logging to proxy/router.go#7902
Merged
Merged
Conversation
Add 6 debug log calls to extractOwnerRepoNumber and StripGHHostPrefix to aid troubleshooting argument parsing and path prefix stripping in the proxy router. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds debug-level logging to internal/proxy/router.go to make request routing and argument parsing easier to trace when DEBUG=proxy:router is enabled.
Changes:
- Added debug logs in
extractOwnerRepoNumberfor entry, float64 parsing, and key error paths. - Added debug log in
StripGHHostPrefixwhen/api/v3is stripped from a path.
Show a summary per file
| File | Description |
|---|---|
| internal/proxy/router.go | Adds router debug logs around argument extraction and GH_HOST prefix stripping. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 3
Comment on lines
82
to
93
| logRouter.Printf("extractOwnerRepoNumber: %s provided as float64, parsing as integer for tool=%s", numberKey, toolName) | ||
| const maxInt64AsFloat = float64(int64(^uint64(0) >> 1)) | ||
| if n < 0 || n > maxInt64AsFloat { | ||
| logRouter.Printf("extractOwnerRepoNumber: %s value out of int64 range for tool=%s", numberKey, toolName) | ||
| err = fmt.Errorf("%s: invalid %s (out of range)", toolName, numberKey) | ||
| return | ||
| } | ||
| i := int64(n) | ||
| if n != float64(i) { | ||
| logRouter.Printf("extractOwnerRepoNumber: %s value is not a whole number for tool=%s", numberKey, toolName) | ||
| err = fmt.Errorf("%s: invalid %s (expected integer)", toolName, numberKey) | ||
| return |
| // from tool arguments, accepting either string or float64 JSON number inputs for | ||
| // the identifier. | ||
| func extractOwnerRepoNumber(argsMap map[string]interface{}, ownerKey, repoKey, numberKey, toolName string) (owner, repo, number string, err error) { | ||
| logRouter.Printf("extractOwnerRepoNumber: tool=%s, keys=%s/%s/%s", toolName, ownerKey, repoKey, numberKey) |
Comment on lines
485
to
486
| logRouter.Printf("StripGHHostPrefix: stripping %s prefix from path", ghHostPathPrefix) | ||
| return strings.TrimPrefix(path, ghHostPathPrefix) |
Collaborator
|
@copilot address review feedback |
Contributor
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.
Adds 6 debug log calls to
internal/proxy/router.gousing the existinglogRouterlogger (proxy:routernamespace).Changes
extractOwnerRepoNumber— the argument-parsing function used by route handlers:float64(JSON number) instead of stringfloat64value is out ofint64range (error path)float64value is not a whole number (error path)owner,repo, or number key) are missing (error path)StripGHHostPrefix— strips the/api/v3prefix added byghwhenGH_HOSTis set:gh-originated requestsValidation
go test ./internal/proxy/— passesgo vet ./internal/proxy/— passesgo build— succeedsEnable