Bug: DingTalk notification builds JSON by string concatenation, echoes the token, leaks resp.Body and swallows errors
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Open cmd/pull_request.go at sendToDingDing (around line 103) and read it together with the goroutines launched in runE (lines 92-97). Fix the three self-contained items first: replace the string-concatenated payload with json.Marshal, delete the fmt.Println that echoes api, and defer resp.Body.Close() after the http.Post; leave the error-swallowing/--strict question as a separate discussion. A unit test can assert the marshalled body is valid JSON for a message containing quotes and newlines, and a passing go test ./cmd/... plus go vet is the done signal.
Written by the indexing model from the issue text.
Description
Description
sendToDingDing in cmd/pull_request.go:103 has four defects:
1. JSON payload is built by string concatenation (line 111):
payload := strings.NewReader(`{"msgtype": "text", "text": {"content": "` + formattedMsg + `"}}`)
Any --msg containing a double quote, backslash or newline produces invalid JSON (or injects arbitrary fields), so DingTalk rejects the request. The message is a Go template over PR data, so quotes are entirely realistic. It should use json.Marshal:
payload, _ := json.Marshal(map[string]any{
"msgtype": "text",
"text": map[string]string{"content": formattedMsg},
})
2. Access token is echoed to stdout (line 112):
fmt.Println(`{"msgtype"...`, api)
api contains ?access_token=…, so the robot token leaks into CI logs. This debug print should be removed.
3. resp.Body is never closed — leaks a connection per notification.
4. Errors are swallowed — the goroutines in runE (lines 92–97) ignore the returned error, and sendToDingDing itself only writes to a writer; a fully failed notification batch still exits 0. If failing silently is intentional for notifications, consider an explicit flag (e.g. --strict) so pipelines can opt into failing on delivery errors.
Items 1–3 are small, self-contained fixes with easy unit tests.
- 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: --token file://… content is not trimmed, trailing newline breaks authenticationPossibly taken @linuxsuren-fs claimed this 6 days ago. Openbug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
LinuxSuRen/gogit#87 ·
-
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 ·
-
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