Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c9adb52
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
68bfc71
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
42bda98
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
b332fe7
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
cd1c5ab
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
7850c7b
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
fb6a190
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
f284e25
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
7369c94
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
c3a1ed9
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
1a082db
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
6ff03fe
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
9316a11
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
19f22d4
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
39ba955
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
e23f24f
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
4e8ffc5
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
501eeec
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
94758e0
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
bf6a6f3
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
ee2ffe2
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
e17f5a2
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
8a13525
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
482ef4f
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
830b57b
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
345a674
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
8478337
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
2c13eda
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
d33c79c
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
0da9e46
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
5a3c3ee
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
fdd84f3
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
5a46463
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
b301830
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
6ce729b
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
9fb2260
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
d703178
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
7e58ef0
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
d626e27
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
fb47bb4
fix(FLEETMDM-002-2): 62 review findings across 40 files
flamingo[bot] Sep 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ee/orbit/pkg/httpsigproxy/httpsigproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func NewProxy(

handler, err := newProxyHandler(targetURL, rootCA, insecure, signer)

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.

🦩 🟠 NewProxy leaks the listener if handler creation fails after listener is bound

In NewProxy, added listener.Close() before returning the error when newProxyHandler fails, preventing the bound TLS listener socket from leaking on that error path.

πŸ€– Prompt for AI agents
In ee/orbit/pkg/httpsigproxy/httpsigproxy.go around line 111, review and complete this code-review fix: NewProxy leaks the listener if handler creation fails after listener is bound.
What the draft fix changed: In `NewProxy`, added `listener.Close()` before returning the error when `newProxyHandler` fails, preventing the bound TLS listener socket from leaking on that error path.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 90 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 NewProxy leaks the listener if handler creation fails after listener is bound

In NewProxy, added listener.Close() before returning the error when newProxyHandler fails, preventing the bound TLS listener socket from leaking on that error path.

πŸ€– Prompt for AI agents
In ee/orbit/pkg/httpsigproxy/httpsigproxy.go around line 111, review and complete this code-review fix: NewProxy leaks the listener if handler creation fails after listener is bound.
What the draft fix changed: In `NewProxy`, added `listener.Close()` before returning the error when `newProxyHandler` fails, preventing the bound TLS listener socket from leaking on that error path.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 90 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 NewProxy leaks the listener if handler creation fails after listener is bound

In NewProxy, added listener.Close() before returning the error when newProxyHandler fails, preventing the bound TLS listener socket from leaking on that error path.

πŸ€– Prompt for AI agents
In ee/orbit/pkg/httpsigproxy/httpsigproxy.go around line 111, review and complete this code-review fix: NewProxy leaks the listener if handler creation fails after listener is bound.
What the draft fix changed: In `NewProxy`, added `listener.Close()` before returning the error when `newProxyHandler` fails, preventing the bound TLS listener socket from leaking on that error path.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 90 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

if err != nil {
listener.Close()
return nil, fmt.Errorf("make proxy handler: %w", err)
}

Expand Down Expand Up @@ -226,7 +227,7 @@ type signingRoundTripper struct {
func (s *signingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {

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.

🦩 🟠 signingRoundTripper wraps error with %#v verb instead of %w, breaking wrapping and readability

Changed the fmt.Errorf format verb from %#v to %w in signingRoundTripper.RoundTrip (in httpsigproxy.go) so the underlying signing error is properly wrapped for errors.Is/errors.As and prints its message instead of a Go-syntax dump.

πŸ€– Prompt for AI agents
In ee/orbit/pkg/httpsigproxy/httpsigproxy.go around line 226, review and complete this code-review fix: signingRoundTripper wraps error with %#v verb instead of %w, breaking wrapping and readability.
What the draft fix changed: Changed the `fmt.Errorf` format verb from `%#v` to `%w` in `signingRoundTripper.RoundTrip` (in httpsigproxy.go) so the underlying signing error is properly wrapped for errors.Is/errors.As and prints its message instead of a Go-syntax dump.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 signingRoundTripper wraps error with %#v verb instead of %w, breaking wrapping and readability

Changed the fmt.Errorf format verb from %#v to %w in signingRoundTripper.RoundTrip (in httpsigproxy.go) so the underlying signing error is properly wrapped for errors.Is/errors.As and prints its message instead of a Go-syntax dump.

πŸ€– Prompt for AI agents
In ee/orbit/pkg/httpsigproxy/httpsigproxy.go around line 226, review and complete this code-review fix: signingRoundTripper wraps error with %#v verb instead of %w, breaking wrapping and readability.
What the draft fix changed: Changed the `fmt.Errorf` format verb from `%#v` to `%w` in `signingRoundTripper.RoundTrip` (in httpsigproxy.go) so the underlying signing error is properly wrapped for errors.Is/errors.As and prints its message instead of a Go-syntax dump.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 signingRoundTripper wraps error with %#v verb instead of %w, breaking wrapping and readability

Changed the fmt.Errorf format verb from %#v to %w in signingRoundTripper.RoundTrip (in httpsigproxy.go) so the underlying signing error is properly wrapped for errors.Is/errors.As and prints its message instead of a Go-syntax dump.

πŸ€– Prompt for AI agents
In ee/orbit/pkg/httpsigproxy/httpsigproxy.go around line 226, review and complete this code-review fix: signingRoundTripper wraps error with %#v verb instead of %w, breaking wrapping and readability.
What the draft fix changed: Changed the `fmt.Errorf` format verb from `%#v` to `%w` in `signingRoundTripper.RoundTrip` (in httpsigproxy.go) so the underlying signing error is properly wrapped for errors.Is/errors.As and prints its message instead of a Go-syntax dump.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

// Sign the request before sending
if err := s.signer.Sign(req); err != nil {
return nil, fmt.Errorf("signing request: %#v", err)
return nil, fmt.Errorf("signing request: %w", err)
}

// Remove X-Forwarded-For because we are forwarding from 127.0.0.1,
Expand Down
5 changes: 3 additions & 2 deletions ee/server/calendar/google_calendar_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"log/slog"
Expand Down Expand Up @@ -126,7 +125,7 @@ func (lowLevelAPI *GoogleCalendarLoadAPI) CreateEvent(event *calendar.Event) (*c
}

func (lowLevelAPI *GoogleCalendarLoadAPI) UpdateEvent(event *calendar.Event) (*calendar.Event, error) {

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.

🦩 🟠 UpdateEvent stub returns unwrapped errors.New without call-site context

In UpdateEvent (ee/server/calendar/google_calendar_load.go), replaced the bare errors.New("GoogleCalendarLoadAPI.UpdateEvent is not implemented") return with fmt.Errorf("update event: %w", errNotImplemented), wrapping a package-level sentinel error errNotImplemented with %w and a short context string, consistent with the fmt.Errorf("...: %w", err) pattern used elsewhere in the file (GetSetting, CreateEvent, GetEvent, ListEvents, DeleteEvent). Kept the errors import since it is now used to define errNotImplemented, and this allows callers to use errors.Is against a stable sentinel while preserving the original message text.

πŸ€– Prompt for AI agents
In ee/server/calendar/google_calendar_load.go around line 128, review and complete this code-review fix: UpdateEvent stub returns unwrapped errors.New without call-site context.
What the draft fix changed: In `UpdateEvent` (ee/server/calendar/google_calendar_load.go), replaced the bare `errors.New("GoogleCalendarLoadAPI.UpdateEvent is not implemented")` return with `fmt.Errorf("update event: %w", errNotImplemented)`, wrapping a package-level sentinel error `errNotImplemented` with `%w` and a short context string, consistent with the `fmt.Errorf("...: %w", err)` pattern used elsewhere in the file (GetSetting, CreateEvent, GetEvent, ListEvents, DeleteEvent). Kept the `errors` import since it is now used to define `errNotImplemented`, and this allows callers to use `errors.Is` against a stable sentinel while preserving the original message text.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 85 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 UpdateEvent stub returns unwrapped errors.New without call-site context

In UpdateEvent (ee/server/calendar/google_calendar_load.go), replaced the bare errors.New("GoogleCalendarLoadAPI.UpdateEvent is not implemented") return with fmt.Errorf("update event: %w", errNotImplemented), wrapping a package-level sentinel error errNotImplemented with %w and a short context string, consistent with the fmt.Errorf("...: %w", err) pattern used elsewhere in the file (GetSetting, CreateEvent, GetEvent, ListEvents, DeleteEvent). Kept the errors import since it is now used to define errNotImplemented, and this allows callers to use errors.Is against a stable sentinel while preserving the original message text.

πŸ€– Prompt for AI agents
In ee/server/calendar/google_calendar_load.go around line 128, review and complete this code-review fix: UpdateEvent stub returns unwrapped errors.New without call-site context.
What the draft fix changed: In `UpdateEvent` (ee/server/calendar/google_calendar_load.go), replaced the bare `errors.New("GoogleCalendarLoadAPI.UpdateEvent is not implemented")` return with `fmt.Errorf("update event: %w", errNotImplemented)`, wrapping a package-level sentinel error `errNotImplemented` with `%w` and a short context string, consistent with the `fmt.Errorf("...: %w", err)` pattern used elsewhere in the file (GetSetting, CreateEvent, GetEvent, ListEvents, DeleteEvent). Kept the `errors` import since it is now used to define `errNotImplemented`, and this allows callers to use `errors.Is` against a stable sentinel while preserving the original message text.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 85 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 UpdateEvent stub returns unwrapped errors.New without call-site context

In UpdateEvent (ee/server/calendar/google_calendar_load.go), replaced the bare errors.New("GoogleCalendarLoadAPI.UpdateEvent is not implemented") return with fmt.Errorf("update event: %w", errNotImplemented), wrapping a package-level sentinel error errNotImplemented with %w and a short context string, consistent with the fmt.Errorf("...: %w", err) pattern used elsewhere in the file (GetSetting, CreateEvent, GetEvent, ListEvents, DeleteEvent). Kept the errors import since it is now used to define errNotImplemented, and this allows callers to use errors.Is against a stable sentinel while preserving the original message text.

πŸ€– Prompt for AI agents
In ee/server/calendar/google_calendar_load.go around line 128, review and complete this code-review fix: UpdateEvent stub returns unwrapped errors.New without call-site context.
What the draft fix changed: In `UpdateEvent` (ee/server/calendar/google_calendar_load.go), replaced the bare `errors.New("GoogleCalendarLoadAPI.UpdateEvent is not implemented")` return with `fmt.Errorf("update event: %w", errNotImplemented)`, wrapping a package-level sentinel error `errNotImplemented` with `%w` and a short context string, consistent with the `fmt.Errorf("...: %w", err)` pattern used elsewhere in the file (GetSetting, CreateEvent, GetEvent, ListEvents, DeleteEvent). Kept the `errors` import since it is now used to define `errNotImplemented`, and this allows callers to use `errors.Is` against a stable sentinel while preserving the original message text.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 85 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

return nil, errors.New("GoogleCalendarLoadAPI.UpdateEvent is not implemented")
return nil, fmt.Errorf("update event: %w", errNotImplemented)
}

func (lowLevelAPI *GoogleCalendarLoadAPI) GetEvent(id, _ string) (*calendar.Event, error) {
Expand Down Expand Up @@ -249,3 +248,5 @@ func (lowLevelAPI *GoogleCalendarLoadAPI) Watch(eventUUID string, channelID stri
func (lowLevelAPI *GoogleCalendarLoadAPI) Stop(channelID string, resourceID string) error {
return nil
}

var errNotImplemented = errors.New("GoogleCalendarLoadAPI.UpdateEvent is not implemented")
3 changes: 2 additions & 1 deletion orbit/cmd/desktop/desktop_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func blockWaitForStopEvent(_ string) error {
func trayIconExists() bool {
conn, err := dbus.SessionBus()

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.

🦩 🟠 dbus.SessionBus() error is logged but not returned, code proceeds with nil conn

In trayIconExists() (orbit/cmd/desktop/desktop_linux.go), added return false and a descriptive .Msg(...) after logging the dbus.SessionBus() error, preventing the subsequent use of a nil *dbus.Conn in conn.Names().

πŸ€– Prompt for AI agents
In orbit/cmd/desktop/desktop_linux.go around line 55, review and complete this code-review fix: dbus.SessionBus() error is logged but not returned, code proceeds with nil conn.
What the draft fix changed: In trayIconExists() (orbit/cmd/desktop/desktop_linux.go), added `return false` and a descriptive `.Msg(...)` after logging the dbus.SessionBus() error, preventing the subsequent use of a nil *dbus.Conn in conn.Names().
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 dbus.SessionBus() error is logged but not returned, code proceeds with nil conn

In trayIconExists() (orbit/cmd/desktop/desktop_linux.go), added return false and a descriptive .Msg(...) after logging the dbus.SessionBus() error, preventing the subsequent use of a nil *dbus.Conn in conn.Names().

πŸ€– Prompt for AI agents
In orbit/cmd/desktop/desktop_linux.go around line 55, review and complete this code-review fix: dbus.SessionBus() error is logged but not returned, code proceeds with nil conn.
What the draft fix changed: In trayIconExists() (orbit/cmd/desktop/desktop_linux.go), added `return false` and a descriptive `.Msg(...)` after logging the dbus.SessionBus() error, preventing the subsequent use of a nil *dbus.Conn in conn.Names().
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 dbus.SessionBus() error is logged but not returned, code proceeds with nil conn

In trayIconExists() (orbit/cmd/desktop/desktop_linux.go), added return false and a descriptive .Msg(...) after logging the dbus.SessionBus() error, preventing the subsequent use of a nil *dbus.Conn in conn.Names().

πŸ€– Prompt for AI agents
In orbit/cmd/desktop/desktop_linux.go around line 55, review and complete this code-review fix: dbus.SessionBus() error is logged but not returned, code proceeds with nil conn.
What the draft fix changed: In trayIconExists() (orbit/cmd/desktop/desktop_linux.go), added `return false` and a descriptive `.Msg(...)` after logging the dbus.SessionBus() error, preventing the subsequent use of a nil *dbus.Conn in conn.Names().
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

if err != nil {
log.Error().Err(err)
log.Error().Err(err).Msg("trayIconExists: connect to session bus")
return false
}

// Get the name we would expect systray to reserve for our tray icon.
Expand Down
2 changes: 1 addition & 1 deletion orbit/pkg/dataflatten/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func JsonFile(file string, opts ...FlattenOpts) ([]Row, error) {

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.

🦩 🟠 Bare error propagation without wrapping in orbit/pkg/dataflatten JSON/plist/JSONL readers

Changed JsonFile in orbit/pkg/dataflatten/json.go to wrap the os.ReadFile error with fmt.Errorf("reading json file %s: %w", file, err) instead of returning it bare, matching the wrapping convention used for the json.Unmarshal error in the same file.

πŸ€– Prompt for AI agents
In orbit/pkg/dataflatten/json.go around line 10, review and complete this code-review fix: Bare error propagation without wrapping in orbit/pkg/dataflatten JSON/plist/JSONL readers.
What the draft fix changed: Changed `JsonFile` in orbit/pkg/dataflatten/json.go to wrap the `os.ReadFile` error with `fmt.Errorf("reading json file %s: %w", file, err)` instead of returning it bare, matching the wrapping convention used for the json.Unmarshal error in the same file.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Bare error propagation without wrapping in orbit/pkg/dataflatten JSON/plist/JSONL readers

Changed JsonFile in orbit/pkg/dataflatten/json.go to wrap the os.ReadFile error with fmt.Errorf("reading json file %s: %w", file, err) instead of returning it bare, matching the wrapping convention used for the json.Unmarshal error in the same file.

πŸ€– Prompt for AI agents
In orbit/pkg/dataflatten/json.go around line 10, review and complete this code-review fix: Bare error propagation without wrapping in orbit/pkg/dataflatten JSON/plist/JSONL readers.
What the draft fix changed: Changed `JsonFile` in orbit/pkg/dataflatten/json.go to wrap the `os.ReadFile` error with `fmt.Errorf("reading json file %s: %w", file, err)` instead of returning it bare, matching the wrapping convention used for the json.Unmarshal error in the same file.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Bare error propagation without wrapping in orbit/pkg/dataflatten JSON/plist/JSONL readers

Changed JsonFile in orbit/pkg/dataflatten/json.go to wrap the os.ReadFile error with fmt.Errorf("reading json file %s: %w", file, err) instead of returning it bare, matching the wrapping convention used for the json.Unmarshal error in the same file.

πŸ€– Prompt for AI agents
In orbit/pkg/dataflatten/json.go around line 10, review and complete this code-review fix: Bare error propagation without wrapping in orbit/pkg/dataflatten JSON/plist/JSONL readers.
What the draft fix changed: Changed `JsonFile` in orbit/pkg/dataflatten/json.go to wrap the `os.ReadFile` error with `fmt.Errorf("reading json file %s: %w", file, err)` instead of returning it bare, matching the wrapping convention used for the json.Unmarshal error in the same file.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

rawdata, err := os.ReadFile(file)
if err != nil {
return nil, err
return nil, fmt.Errorf("reading json file %s: %w", file, err)
}
return Json(rawdata, opts...)
}
Expand Down
2 changes: 1 addition & 1 deletion orbit/pkg/dataflatten/jsonl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func JsonlFile(file string, opts ...FlattenOpts) ([]Row, error) {

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.

🦩 🟠 Bare error propagation without wrapping in jsonl.go file opener

In JsonlFile (orbit/pkg/dataflatten/jsonl.go), the os.Open error is now wrapped with fmt.Errorf("opening jsonl file %s: %w", file, err) instead of being returned bare, matching the error-wrapping style used elsewhere in the file and sibling files. fmt was already imported so no import changes were needed.

πŸ€– Prompt for AI agents
In orbit/pkg/dataflatten/jsonl.go around line 11, review and complete this code-review fix: Bare error propagation without wrapping in jsonl.go file opener.
What the draft fix changed: In `JsonlFile` (orbit/pkg/dataflatten/jsonl.go), the `os.Open` error is now wrapped with `fmt.Errorf("opening jsonl file %s: %w", file, err)` instead of being returned bare, matching the error-wrapping style used elsewhere in the file and sibling files. `fmt` was already imported so no import changes were needed.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Bare error propagation without wrapping in jsonl.go file opener

In JsonlFile (orbit/pkg/dataflatten/jsonl.go), the os.Open error is now wrapped with fmt.Errorf("opening jsonl file %s: %w", file, err) instead of being returned bare, matching the error-wrapping style used elsewhere in the file and sibling files. fmt was already imported so no import changes were needed.

πŸ€– Prompt for AI agents
In orbit/pkg/dataflatten/jsonl.go around line 11, review and complete this code-review fix: Bare error propagation without wrapping in jsonl.go file opener.
What the draft fix changed: In `JsonlFile` (orbit/pkg/dataflatten/jsonl.go), the `os.Open` error is now wrapped with `fmt.Errorf("opening jsonl file %s: %w", file, err)` instead of being returned bare, matching the error-wrapping style used elsewhere in the file and sibling files. `fmt` was already imported so no import changes were needed.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Bare error propagation without wrapping in jsonl.go file opener

In JsonlFile (orbit/pkg/dataflatten/jsonl.go), the os.Open error is now wrapped with fmt.Errorf("opening jsonl file %s: %w", file, err) instead of being returned bare, matching the error-wrapping style used elsewhere in the file and sibling files. fmt was already imported so no import changes were needed.

πŸ€– Prompt for AI agents
In orbit/pkg/dataflatten/jsonl.go around line 11, review and complete this code-review fix: Bare error propagation without wrapping in jsonl.go file opener.
What the draft fix changed: In `JsonlFile` (orbit/pkg/dataflatten/jsonl.go), the `os.Open` error is now wrapped with `fmt.Errorf("opening jsonl file %s: %w", file, err)` instead of being returned bare, matching the error-wrapping style used elsewhere in the file and sibling files. `fmt` was already imported so no import changes were needed.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

f, err := os.Open(file)
if err != nil {
return nil, err
return nil, fmt.Errorf("opening jsonl file %s: %w", file, err)
}
defer f.Close()
return Jsonl(f, opts...)
Expand Down
2 changes: 1 addition & 1 deletion orbit/pkg/dataflatten/plist.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func PlistFile(file string, opts ...FlattenOpts) ([]Row, error) {

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.

🦩 🟠 Bare error propagation without wrapping in plist.go file reader

In PlistFile (orbit/pkg/dataflatten/plist.go), the bare return nil, err from os.ReadFile is now wrapped as fmt.Errorf("reading plist file %s: %w", file, err), matching the wrapping style used for plist.Unmarshal errors and preserving file path context.

πŸ€– Prompt for AI agents
In orbit/pkg/dataflatten/plist.go around line 11, review and complete this code-review fix: Bare error propagation without wrapping in plist.go file reader.
What the draft fix changed: In PlistFile (orbit/pkg/dataflatten/plist.go), the bare `return nil, err` from os.ReadFile is now wrapped as `fmt.Errorf("reading plist file %s: %w", file, err)`, matching the wrapping style used for plist.Unmarshal errors and preserving file path context.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Bare error propagation without wrapping in plist.go file reader

In PlistFile (orbit/pkg/dataflatten/plist.go), the bare return nil, err from os.ReadFile is now wrapped as fmt.Errorf("reading plist file %s: %w", file, err), matching the wrapping style used for plist.Unmarshal errors and preserving file path context.

πŸ€– Prompt for AI agents
In orbit/pkg/dataflatten/plist.go around line 11, review and complete this code-review fix: Bare error propagation without wrapping in plist.go file reader.
What the draft fix changed: In PlistFile (orbit/pkg/dataflatten/plist.go), the bare `return nil, err` from os.ReadFile is now wrapped as `fmt.Errorf("reading plist file %s: %w", file, err)`, matching the wrapping style used for plist.Unmarshal errors and preserving file path context.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Bare error propagation without wrapping in plist.go file reader

In PlistFile (orbit/pkg/dataflatten/plist.go), the bare return nil, err from os.ReadFile is now wrapped as fmt.Errorf("reading plist file %s: %w", file, err), matching the wrapping style used for plist.Unmarshal errors and preserving file path context.

πŸ€– Prompt for AI agents
In orbit/pkg/dataflatten/plist.go around line 11, review and complete this code-review fix: Bare error propagation without wrapping in plist.go file reader.
What the draft fix changed: In PlistFile (orbit/pkg/dataflatten/plist.go), the bare `return nil, err` from os.ReadFile is now wrapped as `fmt.Errorf("reading plist file %s: %w", file, err)`, matching the wrapping style used for plist.Unmarshal errors and preserving file path context.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

rawdata, err := os.ReadFile(file)
if err != nil {
return nil, err
return nil, fmt.Errorf("reading plist file %s: %w", file, err)
}
return Plist(rawdata, opts...)
}
Expand Down
12 changes: 6 additions & 6 deletions orbit/pkg/go-paniclog/paniclog_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package paniclog

import (
"errors"
"fmt"
"os"
"syscall"
)
Expand Down Expand Up @@ -57,28 +57,28 @@ func setStdHandle(stdhandle int32, handle syscall.Handle) error {
func redirectStderr(f *os.File) (UndoFunction, error) {
stderrFd, err := getStdHandle(syscall.STD_ERROR_HANDLE)

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.

🦩 🟠 Bare error return without %w wrapping in redirectStderr

In redirectStderr, the errors.New("Failed to redirect stderr to file: " + err.Error()) on the getStdHandle error path (and its duplicate later in the same function and in the undo closure) is replaced with fmt.Errorf("failed to redirect stderr to file: %w", err), preserving the error chain. The now-unused errors import was replaced with fmt.

πŸ€– Prompt for AI agents
In orbit/pkg/go-paniclog/paniclog_windows.go around line 58, review and complete this code-review fix: Bare error return without %w wrapping in redirectStderr.
What the draft fix changed: In redirectStderr, the `errors.New("Failed to redirect stderr to file: " + err.Error())` on the getStdHandle error path (and its duplicate later in the same function and in the undo closure) is replaced with `fmt.Errorf("failed to redirect stderr to file: %w", err)`, preserving the error chain. The now-unused `errors` import was replaced with `fmt`.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 90 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Bare error return without %w wrapping in redirectStderr

In redirectStderr, the errors.New("Failed to redirect stderr to file: " + err.Error()) on the getStdHandle error path (and its duplicate later in the same function and in the undo closure) is replaced with fmt.Errorf("failed to redirect stderr to file: %w", err), preserving the error chain. The now-unused errors import was replaced with fmt.

πŸ€– Prompt for AI agents
In orbit/pkg/go-paniclog/paniclog_windows.go around line 58, review and complete this code-review fix: Bare error return without %w wrapping in redirectStderr.
What the draft fix changed: In redirectStderr, the `errors.New("Failed to redirect stderr to file: " + err.Error())` on the getStdHandle error path (and its duplicate later in the same function and in the undo closure) is replaced with `fmt.Errorf("failed to redirect stderr to file: %w", err)`, preserving the error chain. The now-unused `errors` import was replaced with `fmt`.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 90 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Bare error return without %w wrapping in redirectStderr

In redirectStderr, the errors.New("Failed to redirect stderr to file: " + err.Error()) on the getStdHandle error path (and its duplicate later in the same function and in the undo closure) is replaced with fmt.Errorf("failed to redirect stderr to file: %w", err), preserving the error chain. The now-unused errors import was replaced with fmt.

πŸ€– Prompt for AI agents
In orbit/pkg/go-paniclog/paniclog_windows.go around line 58, review and complete this code-review fix: Bare error return without %w wrapping in redirectStderr.
What the draft fix changed: In redirectStderr, the `errors.New("Failed to redirect stderr to file: " + err.Error())` on the getStdHandle error path (and its duplicate later in the same function and in the undo closure) is replaced with `fmt.Errorf("failed to redirect stderr to file: %w", err)`, preserving the error chain. The now-unused `errors` import was replaced with `fmt`.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 90 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

if err != nil {
return nil, errors.New("Failed to redirect stderr to file: " + err.Error())
return nil, fmt.Errorf("failed to redirect stderr to file: %w", err)
}

// duplicate the handle to match unix behavior
fHandle, err := dupFD(f.Fd())

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.

🦩 🟠 Bare error return without wrapping in dupFD's caller path (Windows paniclog)

In redirectStderr, the dupFD error path errors.New("Failed to duplicate file: " + err.Error()) is replaced with fmt.Errorf("failed to duplicate file: %w", err), enabling errors.Is/As on the wrapped error. The CloseHandle error in the undo closure was similarly updated to use %w for consistency with the same wrapping convention.

πŸ€– Prompt for AI agents
In orbit/pkg/go-paniclog/paniclog_windows.go around line 64, review and complete this code-review fix: Bare error return without wrapping in dupFD's caller path (Windows paniclog).
What the draft fix changed: In redirectStderr, the dupFD error path `errors.New("Failed to duplicate file: " + err.Error())` is replaced with `fmt.Errorf("failed to duplicate file: %w", err)`, enabling errors.Is/As on the wrapped error. The CloseHandle error in the undo closure was similarly updated to use %w for consistency with the same wrapping convention.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 90 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Bare error return without wrapping in dupFD's caller path (Windows paniclog)

In redirectStderr, the dupFD error path errors.New("Failed to duplicate file: " + err.Error()) is replaced with fmt.Errorf("failed to duplicate file: %w", err), enabling errors.Is/As on the wrapped error. The CloseHandle error in the undo closure was similarly updated to use %w for consistency with the same wrapping convention.

πŸ€– Prompt for AI agents
In orbit/pkg/go-paniclog/paniclog_windows.go around line 64, review and complete this code-review fix: Bare error return without wrapping in dupFD's caller path (Windows paniclog).
What the draft fix changed: In redirectStderr, the dupFD error path `errors.New("Failed to duplicate file: " + err.Error())` is replaced with `fmt.Errorf("failed to duplicate file: %w", err)`, enabling errors.Is/As on the wrapped error. The CloseHandle error in the undo closure was similarly updated to use %w for consistency with the same wrapping convention.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 90 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Bare error return without wrapping in dupFD's caller path (Windows paniclog)

In redirectStderr, the dupFD error path errors.New("Failed to duplicate file: " + err.Error()) is replaced with fmt.Errorf("failed to duplicate file: %w", err), enabling errors.Is/As on the wrapped error. The CloseHandle error in the undo closure was similarly updated to use %w for consistency with the same wrapping convention.

πŸ€– Prompt for AI agents
In orbit/pkg/go-paniclog/paniclog_windows.go around line 64, review and complete this code-review fix: Bare error return without wrapping in dupFD's caller path (Windows paniclog).
What the draft fix changed: In redirectStderr, the dupFD error path `errors.New("Failed to duplicate file: " + err.Error())` is replaced with `fmt.Errorf("failed to duplicate file: %w", err)`, enabling errors.Is/As on the wrapped error. The CloseHandle error in the undo closure was similarly updated to use %w for consistency with the same wrapping convention.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 90 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

if err != nil {
return nil, errors.New("Failed to duplicate file: " + err.Error())
return nil, fmt.Errorf("failed to duplicate file: %w", err)
}

err = setStdHandle(syscall.STD_ERROR_HANDLE, fHandle)
if err != nil {
return nil, errors.New("Failed to redirect stderr to file: " + err.Error())
return nil, fmt.Errorf("failed to redirect stderr to file: %w", err)
}

undo := func() error {
err := setStdHandle(syscall.STD_ERROR_HANDLE, stderrFd)
if err != nil {
return errors.New("Failed to redirect stderr to file: " + err.Error())
return fmt.Errorf("failed to redirect stderr to file: %w", err)
}
err = syscall.CloseHandle(fHandle)
if err != nil {
return errors.New("Failed to close STD_ERROR handle: " + err.Error())
return fmt.Errorf("failed to close STD_ERROR handle: %w", err)
}
return nil
}
Expand Down
3 changes: 3 additions & 0 deletions orbit/pkg/osquery/osquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ func (r *Runner) Execute() error {

// Runner interrupts the running osquery process.
func (r *Runner) Interrupt(err error) {

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.

🦩 🟠 Interrupt() silently discards a nil cancel func without wrapping/logging

In Runner.Interrupt (orbit/pkg/osquery/osquery.go), the previously ignored err parameter is now checked for nil and, if non-nil, wrapped with fmt.Errorf("interrupt osqueryd runner: %w", err) and logged via log.Info().Err(...).Msg(...) (consistent with the existing log.Error().Err(err).Msg(...) pattern already used in NewRunner in this file), before the existing cancel-func logic runs unchanged. This surfaces interrupt errors for debugging shutdown failures without altering the function's signature or control flow.

πŸ€– Prompt for AI agents
In orbit/pkg/osquery/osquery.go around line 184, review and complete this code-review fix: Interrupt() silently discards a nil cancel func without wrapping/logging.
What the draft fix changed: In `Runner.Interrupt` (orbit/pkg/osquery/osquery.go), the previously ignored `err` parameter is now checked for nil and, if non-nil, wrapped with `fmt.Errorf("interrupt osqueryd runner: %w", err)` and logged via `log.Info().Err(...).Msg(...)` (consistent with the existing `log.Error().Err(err).Msg(...)` pattern already used in `NewRunner` in this file), before the existing cancel-func logic runs unchanged. This surfaces interrupt errors for debugging shutdown failures without altering the function's signature or control flow.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 85 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Interrupt() silently discards a nil cancel func without wrapping/logging

In Runner.Interrupt (orbit/pkg/osquery/osquery.go), the previously ignored err parameter is now checked for nil and, if non-nil, wrapped with fmt.Errorf("interrupt osqueryd runner: %w", err) and logged via log.Info().Err(...).Msg(...) (consistent with the existing log.Error().Err(err).Msg(...) pattern already used in NewRunner in this file), before the existing cancel-func logic runs unchanged. This surfaces interrupt errors for debugging shutdown failures without altering the function's signature or control flow.

πŸ€– Prompt for AI agents
In orbit/pkg/osquery/osquery.go around line 184, review and complete this code-review fix: Interrupt() silently discards a nil cancel func without wrapping/logging.
What the draft fix changed: In `Runner.Interrupt` (orbit/pkg/osquery/osquery.go), the previously ignored `err` parameter is now checked for nil and, if non-nil, wrapped with `fmt.Errorf("interrupt osqueryd runner: %w", err)` and logged via `log.Info().Err(...).Msg(...)` (consistent with the existing `log.Error().Err(err).Msg(...)` pattern already used in `NewRunner` in this file), before the existing cancel-func logic runs unchanged. This surfaces interrupt errors for debugging shutdown failures without altering the function's signature or control flow.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 85 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Interrupt() silently discards a nil cancel func without wrapping/logging

In Runner.Interrupt (orbit/pkg/osquery/osquery.go), the previously ignored err parameter is now checked for nil and, if non-nil, wrapped with fmt.Errorf("interrupt osqueryd runner: %w", err) and logged via log.Info().Err(...).Msg(...) (consistent with the existing log.Error().Err(err).Msg(...) pattern already used in NewRunner in this file), before the existing cancel-func logic runs unchanged. This surfaces interrupt errors for debugging shutdown failures without altering the function's signature or control flow.

πŸ€– Prompt for AI agents
In orbit/pkg/osquery/osquery.go around line 184, review and complete this code-review fix: Interrupt() silently discards a nil cancel func without wrapping/logging.
What the draft fix changed: In `Runner.Interrupt` (orbit/pkg/osquery/osquery.go), the previously ignored `err` parameter is now checked for nil and, if non-nil, wrapped with `fmt.Errorf("interrupt osqueryd runner: %w", err)` and logged via `log.Info().Err(...).Msg(...)` (consistent with the existing `log.Error().Err(err).Msg(...)` pattern already used in `NewRunner` in this file), before the existing cancel-func logic runs unchanged. This surfaces interrupt errors for debugging shutdown failures without altering the function's signature or control flow.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 85 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

if err != nil {
log.Info().Err(fmt.Errorf("interrupt osqueryd runner: %w", err)).Msg("osqueryd runner interrupted")
}
if _, cancel := r.getContextAndCancel(); cancel != nil {
cancel()
}
Expand Down
3 changes: 2 additions & 1 deletion orbit/pkg/packaging/linux_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func buildNFPM(opt Options, pkger nfpm.Packager) (string, error) {
}

if opt.Architecture != ArchAmd64 && opt.Architecture != ArchArm64 {

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.

🦩 🟠 buildNFPM bare return without wrapping for architecture validation error

In buildNFPM (orbit/pkg/packaging/linux_shared.go), changed the error string from "Invalid architecture: %s" to "invalid architecture: %s" to conform to Go error string conventions (lowercase, no punctuation) consistent with other errors in the file. Purely a string literal change, no behavior change.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/linux_shared.go around line 59, review and complete this code-review fix: buildNFPM bare return without wrapping for architecture validation error.
What the draft fix changed: In buildNFPM (orbit/pkg/packaging/linux_shared.go), changed the error string from "Invalid architecture: %s" to "invalid architecture: %s" to conform to Go error string conventions (lowercase, no punctuation) consistent with other errors in the file. Purely a string literal change, no behavior change.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 98 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 buildNFPM bare return without wrapping for architecture validation error

In buildNFPM (orbit/pkg/packaging/linux_shared.go), changed the error string from "Invalid architecture: %s" to "invalid architecture: %s" to conform to Go error string conventions (lowercase, no punctuation) consistent with other errors in the file. Purely a string literal change, no behavior change.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/linux_shared.go around line 59, review and complete this code-review fix: buildNFPM bare return without wrapping for architecture validation error.
What the draft fix changed: In buildNFPM (orbit/pkg/packaging/linux_shared.go), changed the error string from "Invalid architecture: %s" to "invalid architecture: %s" to conform to Go error string conventions (lowercase, no punctuation) consistent with other errors in the file. Purely a string literal change, no behavior change.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 98 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 buildNFPM bare return without wrapping for architecture validation error

In buildNFPM (orbit/pkg/packaging/linux_shared.go), changed the error string from "Invalid architecture: %s" to "invalid architecture: %s" to conform to Go error string conventions (lowercase, no punctuation) consistent with other errors in the file. Purely a string literal change, no behavior change.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/linux_shared.go around line 59, review and complete this code-review fix: buildNFPM bare return without wrapping for architecture validation error.
What the draft fix changed: In buildNFPM (orbit/pkg/packaging/linux_shared.go), changed the error string from "Invalid architecture: %s" to "invalid architecture: %s" to conform to Go error string conventions (lowercase, no punctuation) consistent with other errors in the file. Purely a string literal change, no behavior change.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 98 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

return "", fmt.Errorf("Invalid architecture: %s", opt.Architecture)
return "", fmt.Errorf("invalid architecture: %s", opt.Architecture)
}

// Initialize autoupdate metadata
Expand Down Expand Up @@ -543,3 +543,4 @@ pkill fleet-desktop || true

return nil
}

27 changes: 18 additions & 9 deletions orbit/pkg/packaging/macos_rcodesign.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,23 @@ import (
)

func rSign(pkgPath, cert string) error {

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.

🦩 🟠 Private key material written to a predictable path in the shared OS temp directory

In rSign, replaced the fixed-name os.TempDir()/cert.pem file write with os.CreateTemp("", "cert-*.pem") to get a uniquely named temp file, explicitly chmod'd to 0o600 before writing the cert contents, reducing the predictable-path/TOCTOU race window. This changes control flow slightly (explicit Chmod + WriteString + Close with error handling); behavior should be equivalent but the additional error paths introduced are unverified against existing tests, and true hardening would also want O_EXCL semantics guaranteed by CreateTemp (which it already provides) plus possibly restricting the temp dir itself.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 14, review and complete this code-review fix: Private key material written to a predictable path in the shared OS temp directory.
What the draft fix changed: In rSign, replaced the fixed-name os.TempDir()/cert.pem file write with os.CreateTemp("", "cert-*.pem") to get a uniquely named temp file, explicitly chmod'd to 0o600 before writing the cert contents, reducing the predictable-path/TOCTOU race window. This changes control flow slightly (explicit Chmod + WriteString + Close with error handling); behavior should be equivalent but the additional error paths introduced are unverified against existing tests, and true hardening would also want O_EXCL semantics guaranteed by CreateTemp (which it already provides) plus possibly restricting the temp dir itself.
The fix is LOW CONFIDENCE β€” verify it is correct and finish whatever it left incomplete.

fix confidence: πŸ”΄ 55 low β€” review closely β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Private key material written to a predictable path in the shared OS temp directory

In rSign, replaced the fixed-name os.TempDir()/cert.pem file write with os.CreateTemp("", "cert-*.pem") to get a uniquely named temp file, explicitly chmod'd to 0o600 before writing the cert contents, reducing the predictable-path/TOCTOU race window. This changes control flow slightly (explicit Chmod + WriteString + Close with error handling); behavior should be equivalent but the additional error paths introduced are unverified against existing tests, and true hardening would also want O_EXCL semantics guaranteed by CreateTemp (which it already provides) plus possibly restricting the temp dir itself.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 14, review and complete this code-review fix: Private key material written to a predictable path in the shared OS temp directory.
What the draft fix changed: In rSign, replaced the fixed-name os.TempDir()/cert.pem file write with os.CreateTemp("", "cert-*.pem") to get a uniquely named temp file, explicitly chmod'd to 0o600 before writing the cert contents, reducing the predictable-path/TOCTOU race window. This changes control flow slightly (explicit Chmod + WriteString + Close with error handling); behavior should be equivalent but the additional error paths introduced are unverified against existing tests, and true hardening would also want O_EXCL semantics guaranteed by CreateTemp (which it already provides) plus possibly restricting the temp dir itself.
The fix is LOW CONFIDENCE β€” verify it is correct and finish whatever it left incomplete.

fix confidence: πŸ”΄ 55 low β€” review closely β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Private key material written to a predictable path in the shared OS temp directory

In rSign, replaced the fixed-name os.TempDir()/cert.pem file write with os.CreateTemp("", "cert-*.pem") to get a uniquely named temp file, explicitly chmod'd to 0o600 before writing the cert contents, reducing the predictable-path/TOCTOU race window. This changes control flow slightly (explicit Chmod + WriteString + Close with error handling); behavior should be equivalent but the additional error paths introduced are unverified against existing tests, and true hardening would also want O_EXCL semantics guaranteed by CreateTemp (which it already provides) plus possibly restricting the temp dir itself.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 14, review and complete this code-review fix: Private key material written to a predictable path in the shared OS temp directory.
What the draft fix changed: In rSign, replaced the fixed-name os.TempDir()/cert.pem file write with os.CreateTemp("", "cert-*.pem") to get a uniquely named temp file, explicitly chmod'd to 0o600 before writing the cert contents, reducing the predictable-path/TOCTOU race window. This changes control flow slightly (explicit Chmod + WriteString + Close with error handling); behavior should be equivalent but the additional error paths introduced are unverified against existing tests, and true hardening would also want O_EXCL semantics guaranteed by CreateTemp (which it already provides) plus possibly restricting the temp dir itself.
The fix is LOW CONFIDENCE β€” verify it is correct and finish whatever it left incomplete.

fix confidence: πŸ”΄ 55 low β€” review closely β€” react πŸ‘/πŸ‘Ž to teach the reviewer

pemPath := filepath.Join(os.TempDir(), "cert.pem")
defer os.Remove(pemPath)
err := os.WriteFile(pemPath, []byte(cert), 0o600)
pemFile, err := os.CreateTemp("", "cert-*.pem")
if err != nil {
return fmt.Errorf("creating cert temp file: %s", err)
}
pemPath := pemFile.Name()
defer os.Remove(pemPath)
if err := pemFile.Chmod(0o600); err != nil {
pemFile.Close()
return fmt.Errorf("setting cert temp file permissions: %s", err)
}
if _, err := pemFile.WriteString(cert); err != nil {
pemFile.Close()
return fmt.Errorf("writing cert data: %s", err)
}
if err := pemFile.Close(); err != nil {
return fmt.Errorf("closing cert temp file: %s", err)
}

return retry.Do(func() error {
var outBuf bytes.Buffer
Expand All @@ -30,8 +41,7 @@ func rSign(pkgPath, cert string) error {
cmd.Stdout = &outBuf
cmd.Stderr = &outBuf
if err := cmd.Run(); err != nil {

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.

🦩 🟠 rSign swallows underlying error detail by printing to stdout instead of wrapping into returned error

In rSign, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign: %w: %s"), so the rcodesign output is available to callers/error handling.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 32, review and complete this code-review fix: rSign swallows underlying error detail by printing to stdout instead of wrapping into returned error.
What the draft fix changed: In rSign, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign: %w: %s"), so the rcodesign output is available to callers/error handling.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 80 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 rSign swallows underlying error detail by printing to stdout instead of wrapping into returned error

In rSign, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign: %w: %s"), so the rcodesign output is available to callers/error handling.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 32, review and complete this code-review fix: rSign swallows underlying error detail by printing to stdout instead of wrapping into returned error.
What the draft fix changed: In rSign, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign: %w: %s"), so the rcodesign output is available to callers/error handling.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 80 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 rSign swallows underlying error detail by printing to stdout instead of wrapping into returned error

In rSign, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign: %w: %s"), so the rcodesign output is available to callers/error handling.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 32, review and complete this code-review fix: rSign swallows underlying error detail by printing to stdout instead of wrapping into returned error.
What the draft fix changed: In rSign, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign: %w: %s"), so the rcodesign output is available to callers/error handling.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 80 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

fmt.Println(outBuf.String())
return fmt.Errorf("rcodesign: %w", err)
return fmt.Errorf("rcodesign: %w: %s", err, outBuf.String())
}
return nil
}, retry.WithMaxAttempts(3))
Expand All @@ -56,8 +66,7 @@ func rNotarizeStaple(pkg, apiKeyID, apiKeyIssuer, apiKeyContent string) error {
cmd.Stdout = &outBuf
cmd.Stderr = &outBuf
if err := cmd.Run(); err != nil {

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.

🦩 🟠 rNotarizeStaple swallows rcodesign notarize output instead of returning it in the error

In rNotarizeStaple, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign notarize: %w: %s"), preserving diagnostic output in the error itself.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 58, review and complete this code-review fix: rNotarizeStaple swallows rcodesign notarize output instead of returning it in the error.
What the draft fix changed: In rNotarizeStaple, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign notarize: %w: %s"), preserving diagnostic output in the error itself.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 80 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 rNotarizeStaple swallows rcodesign notarize output instead of returning it in the error

In rNotarizeStaple, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign notarize: %w: %s"), preserving diagnostic output in the error itself.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 58, review and complete this code-review fix: rNotarizeStaple swallows rcodesign notarize output instead of returning it in the error.
What the draft fix changed: In rNotarizeStaple, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign notarize: %w: %s"), preserving diagnostic output in the error itself.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 80 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 rNotarizeStaple swallows rcodesign notarize output instead of returning it in the error

In rNotarizeStaple, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign notarize: %w: %s"), preserving diagnostic output in the error itself.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 58, review and complete this code-review fix: rNotarizeStaple swallows rcodesign notarize output instead of returning it in the error.
What the draft fix changed: In rNotarizeStaple, removed the fmt.Println(outBuf.String()) call and instead embedded outBuf.String() into the returned wrapped error ("rcodesign notarize: %w: %s"), preserving diagnostic output in the error itself.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 80 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

fmt.Println(outBuf.String())
return fmt.Errorf("rcodesign notarize: %w", err)
return fmt.Errorf("rcodesign notarize: %w: %s", err, outBuf.String())
}
return nil
}, retry.WithMaxAttempts(3))
Expand All @@ -72,8 +81,8 @@ func writeAPIKeys(issuer, id, content string) (string, error) {
// The underliying tools (rcodesign and Transporter) expect to find a
// certificate key in this path.
path := filepath.Join(homedir, ".appstoreconnect", "private_keys")

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.

🦩 🟠 writeAPIKeys error message says 'finding home dir' when the actual failing operation is MkdirAll

Changed the error message in writeAPIKeys (macos_rcodesign.go) for the secure.MkdirAll failure from "finding home dir" to "creating private keys dir", correctly describing the failing operation.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 74, review and complete this code-review fix: writeAPIKeys error message says 'finding home dir' when the actual failing operation is MkdirAll.
What the draft fix changed: Changed the error message in writeAPIKeys (macos_rcodesign.go) for the secure.MkdirAll failure from "finding home dir" to "creating private keys dir", correctly describing the failing operation.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 secure.MkdirAll called with file-permission mode 0o600 instead of a directory mode

Changed the mode argument passed to secure.MkdirAll in writeAPIKeys from 0o600 to 0o700, giving the owner execute/traversal permission needed for a usable directory.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 74, review and complete this code-review fix: secure.MkdirAll called with file-permission mode 0o600 instead of a directory mode.
What the draft fix changed: Changed the mode argument passed to secure.MkdirAll in writeAPIKeys from 0o600 to 0o700, giving the owner execute/traversal permission needed for a usable directory.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 90 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 writeAPIKeys error message says 'finding home dir' when the actual failing operation is MkdirAll

Changed the error message in writeAPIKeys (macos_rcodesign.go) for the secure.MkdirAll failure from "finding home dir" to "creating private keys dir", correctly describing the failing operation.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 74, review and complete this code-review fix: writeAPIKeys error message says 'finding home dir' when the actual failing operation is MkdirAll.
What the draft fix changed: Changed the error message in writeAPIKeys (macos_rcodesign.go) for the secure.MkdirAll failure from "finding home dir" to "creating private keys dir", correctly describing the failing operation.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 secure.MkdirAll called with file-permission mode 0o600 instead of a directory mode

Changed the mode argument passed to secure.MkdirAll in writeAPIKeys from 0o600 to 0o700, giving the owner execute/traversal permission needed for a usable directory.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 74, review and complete this code-review fix: secure.MkdirAll called with file-permission mode 0o600 instead of a directory mode.
What the draft fix changed: Changed the mode argument passed to secure.MkdirAll in writeAPIKeys from 0o600 to 0o700, giving the owner execute/traversal permission needed for a usable directory.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 90 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 writeAPIKeys error message says 'finding home dir' when the actual failing operation is MkdirAll

Changed the error message in writeAPIKeys (macos_rcodesign.go) for the secure.MkdirAll failure from "finding home dir" to "creating private keys dir", correctly describing the failing operation.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 74, review and complete this code-review fix: writeAPIKeys error message says 'finding home dir' when the actual failing operation is MkdirAll.
What the draft fix changed: Changed the error message in writeAPIKeys (macos_rcodesign.go) for the secure.MkdirAll failure from "finding home dir" to "creating private keys dir", correctly describing the failing operation.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 secure.MkdirAll called with file-permission mode 0o600 instead of a directory mode

Changed the mode argument passed to secure.MkdirAll in writeAPIKeys from 0o600 to 0o700, giving the owner execute/traversal permission needed for a usable directory.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/macos_rcodesign.go around line 74, review and complete this code-review fix: secure.MkdirAll called with file-permission mode 0o600 instead of a directory mode.
What the draft fix changed: Changed the mode argument passed to secure.MkdirAll in writeAPIKeys from 0o600 to 0o700, giving the owner execute/traversal permission needed for a usable directory.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 90 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

if err = secure.MkdirAll(path, 0o600); err != nil {
return "", fmt.Errorf("finding home dir: %s", err)
if err = secure.MkdirAll(path, 0o700); err != nil {
return "", fmt.Errorf("creating private keys dir: %s", err)
}

keyPath := filepath.Join(path, fmt.Sprintf("AuthKey_%s.p8", id))
Expand Down
27 changes: 25 additions & 2 deletions orbit/pkg/packaging/wix/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/xml"
"fmt"
"os"
"path/filepath"
"strings"
)

Expand Down Expand Up @@ -64,13 +65,35 @@ func TransformHeat(path string) error {
return fmt.Errorf("marshal xml: %w", err)
}

// Write to a temp file in the same directory first, then rename over the
// original. This avoids destroying the original file if the write fails,
// and the rename is atomic on the same filesystem.
dir := filepath.Dir(path)
tmp, err := os.CreateTemp(dir, filepath.Base(path)+".tmp-*")
if err != nil {
return fmt.Errorf("create temp file: %w", err)
}
tmpPath := tmp.Name()
defer os.Remove(tmpPath)

if _, err := tmp.Write(contents); err != nil {
tmp.Close()
return fmt.Errorf("write temp file: %w", err)
}
if err := tmp.Close(); err != nil {
return fmt.Errorf("close temp file: %w", err)
}
if err := os.Chmod(tmpPath, 0o600); err != nil {
return fmt.Errorf("chmod temp file: %w", err)
}

// Remove first as we encounter permission errors on some Linux configurations.

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.

🦩 🟠 os.Remove/os.WriteFile errors in TransformHeat wrapped correctly, but os.Remove precedes overwrite risk without recovery

In TransformHeat (orbit/pkg/packaging/wix/transform.go), replaced the direct os.Remove followed by os.WriteFile with a write-to-temp-then-rename approach: the marshaled contents are first written to a temp file (os.CreateTemp in the same directory, with a deferred os.Remove cleanup for the temp path), permissions set to 0o600 via os.Chmod, and only after the temp write/close/chmod succeed is the original file removed and the temp file renamed into place via os.Rename. This ensures the write is confirmed successful before the original is destroyed. Note the finding's suggestion of "atomic rename over the original" is only fully atomic on POSIX systems where rename can replace an existing file directly; the original os.Remove-before-write pattern (kept here, now after temp write succeeds) was there specifically to work around Windows/Linux permission quirks, so os.Remove is still called before os.Rename rather than relying on Rename to overwrite directly β€” this preserves the original permission workaround while eliminating the data-loss window, though there remains a narrow window between os.Remove and os.Rename where no file exists, which is a residual (much smaller) risk versus a fully atomic solution.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/wix/transform.go around line 67, review and complete this code-review fix: os.Remove/os.WriteFile errors in TransformHeat wrapped correctly, but os.Remove precedes overwrite risk without recovery.
What the draft fix changed: In TransformHeat (orbit/pkg/packaging/wix/transform.go), replaced the direct os.Remove followed by os.WriteFile with a write-to-temp-then-rename approach: the marshaled contents are first written to a temp file (os.CreateTemp in the same directory, with a deferred os.Remove cleanup for the temp path), permissions set to 0o600 via os.Chmod, and only after the temp write/close/chmod succeed is the original file removed and the temp file renamed into place via os.Rename. This ensures the write is confirmed successful before the original is destroyed. Note the finding's suggestion of "atomic rename over the original" is only fully atomic on POSIX systems where rename can replace an existing file directly; the original os.Remove-before-write pattern (kept here, now after temp write succeeds) was there specifically to work around Windows/Linux permission quirks, so os.Remove is still called before os.Rename rather than relying on Rename to overwrite directly β€” this preserves the original permission workaround while eliminating the data-loss window, though there remains a narrow window between os.Remove and os.Rename where no file exists, which is a residual (much smaller) risk versus a fully atomic solution.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 65 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 os.Remove/os.WriteFile errors in TransformHeat wrapped correctly, but os.Remove precedes overwrite risk without recovery

In TransformHeat (orbit/pkg/packaging/wix/transform.go), replaced the direct os.Remove followed by os.WriteFile with a write-to-temp-then-rename approach: the marshaled contents are first written to a temp file (os.CreateTemp in the same directory, with a deferred os.Remove cleanup for the temp path), permissions set to 0o600 via os.Chmod, and only after the temp write/close/chmod succeed is the original file removed and the temp file renamed into place via os.Rename. This ensures the write is confirmed successful before the original is destroyed. Note the finding's suggestion of "atomic rename over the original" is only fully atomic on POSIX systems where rename can replace an existing file directly; the original os.Remove-before-write pattern (kept here, now after temp write succeeds) was there specifically to work around Windows/Linux permission quirks, so os.Remove is still called before os.Rename rather than relying on Rename to overwrite directly β€” this preserves the original permission workaround while eliminating the data-loss window, though there remains a narrow window between os.Remove and os.Rename where no file exists, which is a residual (much smaller) risk versus a fully atomic solution.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/wix/transform.go around line 67, review and complete this code-review fix: os.Remove/os.WriteFile errors in TransformHeat wrapped correctly, but os.Remove precedes overwrite risk without recovery.
What the draft fix changed: In TransformHeat (orbit/pkg/packaging/wix/transform.go), replaced the direct os.Remove followed by os.WriteFile with a write-to-temp-then-rename approach: the marshaled contents are first written to a temp file (os.CreateTemp in the same directory, with a deferred os.Remove cleanup for the temp path), permissions set to 0o600 via os.Chmod, and only after the temp write/close/chmod succeed is the original file removed and the temp file renamed into place via os.Rename. This ensures the write is confirmed successful before the original is destroyed. Note the finding's suggestion of "atomic rename over the original" is only fully atomic on POSIX systems where rename can replace an existing file directly; the original os.Remove-before-write pattern (kept here, now after temp write succeeds) was there specifically to work around Windows/Linux permission quirks, so os.Remove is still called before os.Rename rather than relying on Rename to overwrite directly β€” this preserves the original permission workaround while eliminating the data-loss window, though there remains a narrow window between os.Remove and os.Rename where no file exists, which is a residual (much smaller) risk versus a fully atomic solution.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 65 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 os.Remove/os.WriteFile errors in TransformHeat wrapped correctly, but os.Remove precedes overwrite risk without recovery

In TransformHeat (orbit/pkg/packaging/wix/transform.go), replaced the direct os.Remove followed by os.WriteFile with a write-to-temp-then-rename approach: the marshaled contents are first written to a temp file (os.CreateTemp in the same directory, with a deferred os.Remove cleanup for the temp path), permissions set to 0o600 via os.Chmod, and only after the temp write/close/chmod succeed is the original file removed and the temp file renamed into place via os.Rename. This ensures the write is confirmed successful before the original is destroyed. Note the finding's suggestion of "atomic rename over the original" is only fully atomic on POSIX systems where rename can replace an existing file directly; the original os.Remove-before-write pattern (kept here, now after temp write succeeds) was there specifically to work around Windows/Linux permission quirks, so os.Remove is still called before os.Rename rather than relying on Rename to overwrite directly β€” this preserves the original permission workaround while eliminating the data-loss window, though there remains a narrow window between os.Remove and os.Rename where no file exists, which is a residual (much smaller) risk versus a fully atomic solution.

πŸ€– Prompt for AI agents
In orbit/pkg/packaging/wix/transform.go around line 67, review and complete this code-review fix: os.Remove/os.WriteFile errors in TransformHeat wrapped correctly, but os.Remove precedes overwrite risk without recovery.
What the draft fix changed: In TransformHeat (orbit/pkg/packaging/wix/transform.go), replaced the direct os.Remove followed by os.WriteFile with a write-to-temp-then-rename approach: the marshaled contents are first written to a temp file (os.CreateTemp in the same directory, with a deferred os.Remove cleanup for the temp path), permissions set to 0o600 via os.Chmod, and only after the temp write/close/chmod succeed is the original file removed and the temp file renamed into place via os.Rename. This ensures the write is confirmed successful before the original is destroyed. Note the finding's suggestion of "atomic rename over the original" is only fully atomic on POSIX systems where rename can replace an existing file directly; the original os.Remove-before-write pattern (kept here, now after temp write succeeds) was there specifically to work around Windows/Linux permission quirks, so os.Remove is still called before os.Rename rather than relying on Rename to overwrite directly β€” this preserves the original permission workaround while eliminating the data-loss window, though there remains a narrow window between os.Remove and os.Rename where no file exists, which is a residual (much smaller) risk versus a fully atomic solution.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 65 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

if err := os.Remove(path); err != nil {
return fmt.Errorf("remove old file: %w", err)
}

if err := os.WriteFile(path, contents, 0o600); err != nil {
return fmt.Errorf("write file: %w", err)
if err := os.Rename(tmpPath, path); err != nil {
return fmt.Errorf("rename temp file: %w", err)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion orbit/pkg/table/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (r *Runner) Execute() error {
r.srv.RegisterPlugin(plugins...)

if err := r.srv.Run(); err != nil {

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.

🦩 🟠 Bare error return without wrapping in table extension.go Execute()

In Runner.Execute(), changed if err := r.srv.Run(); err != nil { return err } to return fmt.Errorf("running extension manager server: %w", err), matching the wrapping convention used elsewhere in the file (fmt already imported).

πŸ€– Prompt for AI agents
In orbit/pkg/table/extension.go around line 131, review and complete this code-review fix: Bare error return without wrapping in table extension.go Execute().
What the draft fix changed: In `Runner.Execute()`, changed `if err := r.srv.Run(); err != nil { return err }` to `return fmt.Errorf("running extension manager server: %w", err)`, matching the wrapping convention used elsewhere in the file (`fmt` already imported).
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Bare error return without wrapping in table extension.go Execute()

In Runner.Execute(), changed if err := r.srv.Run(); err != nil { return err } to return fmt.Errorf("running extension manager server: %w", err), matching the wrapping convention used elsewhere in the file (fmt already imported).

πŸ€– Prompt for AI agents
In orbit/pkg/table/extension.go around line 131, review and complete this code-review fix: Bare error return without wrapping in table extension.go Execute().
What the draft fix changed: In `Runner.Execute()`, changed `if err := r.srv.Run(); err != nil { return err }` to `return fmt.Errorf("running extension manager server: %w", err)`, matching the wrapping convention used elsewhere in the file (`fmt` already imported).
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

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.

🦩 🟠 Bare error return without wrapping in table extension.go Execute()

In Runner.Execute(), changed if err := r.srv.Run(); err != nil { return err } to return fmt.Errorf("running extension manager server: %w", err), matching the wrapping convention used elsewhere in the file (fmt already imported).

πŸ€– Prompt for AI agents
In orbit/pkg/table/extension.go around line 131, review and complete this code-review fix: Bare error return without wrapping in table extension.go Execute().
What the draft fix changed: In `Runner.Execute()`, changed `if err := r.srv.Run(); err != nil { return err }` to `return fmt.Errorf("running extension manager server: %w", err)`, matching the wrapping convention used elsewhere in the file (`fmt` already imported).
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 95 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

return err
return fmt.Errorf("running extension manager server: %w", err)
}

return nil
Expand Down
Loading