Skip to content

fix(FLEETMDM-002-2): CU-86akj32d7 3 review findings across 3 files - #176

Draft
flamingo[bot] wants to merge 3 commits into
mainfrom
ai-fix/fleetmdm-002-2-d1d028e9-1446a072
Draft

flamingo[bot] wants to merge 3 commits into
mainfrom
ai-fix/fleetmdm-002-2-d1d028e9-1446a072

Conversation

@flamingo

@flamingo flamingo Bot commented Sep 14, 2026

Copy link
Copy Markdown

Closes 3 review findings across 3 files.

Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.

# Fix confidence Finding Location
1 🟢 90 high sync() in macoffice/sync.go returns errors from ghClient/fsClient calls without wrapping context server/vulnerabilities/macoffice/sync.go:33
2 🟢 90 high getRawBody swallows the read error on non-200 responses instead of wrapping it server/service/client_debug.go:18
3 🟢 92 high machineId header injection swallows a nil machineIdProvider silently without any wrapped error or log context client/orbit_client.go:190

What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.


Run: https://product-hub.flamingo.so/admin/code-review
Run id: 1446a072-096e-4294-8082-c7cadffe76de

Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.

ClickUp task: CU-86akj32d7 FleetMDM bulk review findings sweep (12 PRs)

@flamingo flamingo Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 What this fix changed, finding by finding

3 finding(s) fixed in this draft — 3 explained inline on the diff.

@@ -32,7 +32,7 @@ func sync(
) error {
remote, url, err := ghClient.MacOfficeReleaseNotes(ctx)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 sync() in macoffice/sync.go returns errors from ghClient/fsClient calls without wrapping context

In sync() (server/vulnerabilities/macoffice/sync.go), wrapped all four bare return err propagation points with contextual fmt.Errorf("...: %w", err) messages: "get remote release notes" for ghClient.MacOfficeReleaseNotes, "get local release notes" for fsClient.MacOfficeReleaseNotes, "download release notes" for both ghClient.Download call sites, and "delete out of date release notes" for fsClient.Delete. This preserves error unwrapping via %w while adding distinguishable context at each call boundary, addressing FLEETMDM-002-2 without altering control flow, style, or the top-level SyncFromGithub wrapping.

🤖 Prompt for AI agents
In server/vulnerabilities/macoffice/sync.go around line 33, review and complete this code-review fix: sync() in macoffice/sync.go returns errors from ghClient/fsClient calls without wrapping context.
What the draft fix changed: In sync() (server/vulnerabilities/macoffice/sync.go), wrapped all four bare `return err` propagation points with contextual `fmt.Errorf("...: %w", err)` messages: "get remote release notes" for ghClient.MacOfficeReleaseNotes, "get local release notes" for fsClient.MacOfficeReleaseNotes, "download release notes" for both ghClient.Download call sites, and "delete out of date release notes" for fsClient.Delete. This preserves error unwrapping via %w while adding distinguishable context at each call boundary, addressing FLEETMDM-002-2 without altering control flow, style, or the top-level SyncFromGithub wrapping.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer

Comment on lines 20 to 28
if err == nil && len(body) > 0 {
return nil, fmt.Errorf("get %s received status %d: %s", endpoint, response.StatusCode, body)
}
if err != nil {
return nil, fmt.Errorf("get %s received status %d, read response body: %w", endpoint, response.StatusCode, err)
}
return nil, fmt.Errorf("get %s received status %d", endpoint, response.StatusCode)
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 getRawBody swallows the read error on non-200 responses instead of wrapping it

In getRawBody (server/service/client_debug.go), the non-200 branch now checks the io.ReadAll error separately: if err != nil, the error is wrapped with %w into a new error message that also includes the status code, instead of being silently discarded and replaced by a generic status-only message. The success path (empty body, no error) still falls through to the generic status-only message unchanged.

🤖 Prompt for AI agents
In server/service/client_debug.go around line 18, review and complete this code-review fix: getRawBody swallows the read error on non-200 responses instead of wrapping it.
What the draft fix changed: In getRawBody (server/service/client_debug.go), the non-200 branch now checks the io.ReadAll error separately: if err != nil, the error is wrapped with %w into a new error message that also includes the status code, instead of being silently discarded and replaced by a generic status-only message. The success path (empty body, no error) still falls through to the generic status-only message unchanged.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer

Comment thread client/orbit_client.go
Comment on lines 192 to 199
if machineId != "" {
request.Header.Add("x-machine-id", machineId)
}
} else {
log.Debug().Msg("machineIdProvider is nil, not adding x-machine-id header")
}
}
// <<< OPENFRAME(agent-openframe-mode)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 machineId header injection swallows a nil machineIdProvider silently without any wrapped error or log context

In requestWithExternal (client/orbit_client.go), added an else branch to the if oc.machineIdProvider != nil check that logs log.Debug().Msg("machineIdProvider is nil, not adding x-machine-id header"), mirroring the existing Debug log used in the authToken-empty branch just above it. This gives log parity between the two header-injection paths without altering control flow, header behavior, or any other logic.

🤖 Prompt for AI agents
In client/orbit_client.go around line 190, review and complete this code-review fix: machineId header injection swallows a nil machineIdProvider silently without any wrapped error or log context.
What the draft fix changed: In `requestWithExternal` (client/orbit_client.go), added an `else` branch to the `if oc.machineIdProvider != nil` check that logs `log.Debug().Msg("machineIdProvider is nil, not adding x-machine-id header")`, mirroring the existing Debug log used in the authToken-empty branch just above it. This gives log parity between the two header-injection paths without altering control flow, header behavior, or any other logic.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 92 high — react 👍/👎 to teach the reviewer

@flamingo flamingo Bot changed the title fix(FLEETMDM-002-2): 3 review findings across 3 files fix(FLEETMDM-002-2): CU-86akj32d7 3 review findings across 3 files Sep 15, 2026
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.

0 participants