Bug: --token file://… content is not trimmed, trailing newline breaks authentication
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 88/100
Research direction
The read happens in cmd/status.go around line 52, in the file:// branch of the token option handling; start by reading that block and the surrounding status option struct to see where o.token is consumed afterwards. Change the assignment to trim whitespace from the file contents and wrap the read error with the attempted path so failures name the file. Done means a token file ending in a newline authenticates, and go build ./... plus the existing tests under cmd/ still pass.
Written by the indexing model from the issue text.
Description
Description
gogit status supports reading the token from a file — cmd/status.go:52:
if strings.HasPrefix(o.token, "file://") {
tokenFile := strings.TrimPrefix(o.token, "file://")
var data []byte
if data, err = os.ReadFile(tokenFile); err == nil {
o.token = string(data)
}
}
The content is used as-is. Token files very commonly carry a trailing newline (Kubernetes secrets written via stringData, echo $TOKEN > file, editors), and then every API call fails authentication with a confusing provider error such as 401 Unauthorized, because the token sent is <token>\n.
Also note the error from a failed read is returned as-is with no context about which file was attempted.
Suggested fix
o.token = strings.TrimSpace(string(data))
plus wrap the read error with the file path. One-line fix, big usability win for the documented file:///var/token use case.
- Dominant language
- Go
- Stars
- 19
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from LinuxSuRen/gogit
-
Docs: replace the real-looking access token in README examples and fix build status help textsPossibly taken @linuxsuren-fs claimed this 6 days ago. Opendocumentation good first issue
Difficulty 1/5 Under an hour Newbie friendliness 88/100
LinuxSuRen/gogit#90 ·
-
Bug: gogit checkout robustness: remotes[0] panic, wrong error message, empty version output, non-idempotent 0444 writesPossibly taken @linuxsuren-fs claimed this 6 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
LinuxSuRen/gogit#86 ·
-
Bug: gogit checkout fails on repositories whose default branch is not masterPossibly taken @linuxsuren-fs claimed this 6 days ago. Openbug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
LinuxSuRen/gogit#85 ·
-
Bug: DingTalk notification builds JSON by string concatenation, echoes the token, leaks resp.Body and swallows errorsPossibly taken @linuxsuren-fs claimed this 6 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
LinuxSuRen/gogit#84 ·
-
Security: git access token is printed into pod logs by the Argo Workflows executorPossibly taken @linuxsuren-fs claimed this 6 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
LinuxSuRen/gogit#83 ·
All issues in LinuxSuRen/gogit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
aminueza/terraform-provider-minio#1406 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
kubernetes/kubeadm#3339 ·
-
A failed hydrate call can be dropped when the row's wait is ready tooPossibly taken @turbot-agent-fleet claimed this today. Openagent:ready
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
turbot/steampipe-plugin-sdk#1018 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
speakeasy-api/speakeasy#2159 ·
Maintainers usually reply within 1 day
-
enhancement needs-review
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day