-
Notifications
You must be signed in to change notification settings - Fork 1
fix(FLEETMDM-002-2): CU-86akbhhtv 37 review findings across 32 files #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d5e7014
1f82791
a0d56cd
ff0b47d
2463fcd
c6e2def
acd0731
5335150
fcdaab5
6673a95
1760faa
d920560
ba91e79
91674c0
b9aadb5
b365257
18c146b
82a5c80
1b685f5
dbee11f
0b2a2e6
356f11a
e052e2f
30c44cb
4514078
db7c7c2
ef66c59
fb22509
3053cc2
be69b81
0f8ade8
22150ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,7 +153,7 @@ func downloadLatestGitHubAsset(dbDir, fileName string) error { | |
| defer resp.Body.Close() | ||
|
|
||
| if resp.StatusCode != http.StatusOK { | ||
| return fmt.Errorf("get last mod start date: %w", fmt.Errorf("unexpected status code %d", resp.StatusCode)) | ||
| return fmt.Errorf("unexpected status code %d fetching %s", resp.StatusCode, fileName) | ||
| } | ||
|
|
||
| lastModStartDate, err := io.ReadAll(resp.Body) | ||
|
|
@@ -271,11 +271,26 @@ func gunzipFileToDisk(filename, dbpath string) error { | |
|
|
||
| // Using a maxBytes limit to prevent decompression bombs: gosec G110 | ||
| maxBytes := 200 * 1024 * 1024 // 200MB | ||
| _, err = io.CopyN(out, gz, int64(maxBytes)) | ||
| written, err := io.CopyN(out, gz, int64(maxBytes)) | ||
| if err != nil && err != io.EOF { | ||
| msg := fmt.Sprintf("error copying file %s: %v", f.Name(), err) | ||
| panic(msg) | ||
| } | ||
| if written == int64(maxBytes) { | ||
| // Check if there is more data beyond the limit, which means the file | ||
| // exceeds maxBytes and was not fully copied; fail rather than silently | ||
| // truncate. | ||
| extra := make([]byte, 1) | ||
| n, peekErr := gz.Read(extra) | ||
| if n > 0 { | ||
| msg := fmt.Sprintf("error copying file %s: exceeds maximum allowed size of %d bytes", f.Name(), maxBytes) | ||
| panic(msg) | ||
| } | ||
| if peekErr != nil && peekErr != io.EOF { | ||
| msg := fmt.Sprintf("error copying file %s: %v", f.Name(), peekErr) | ||
| panic(msg) | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
Comment on lines
271
to
296
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π io.CopyN uses a fixed 200MB cap but silently truncates larger files instead of failing the decompression-bomb guard In π€ Prompt for AI agentsfix confidence: π΄ 55 low β review closely β react π/π to teach the reviewer |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,8 @@ func blockWaitForStopEvent(_ string) error { | |
| func trayIconExists() bool { | ||
| conn, err := dbus.SessionBus() | ||
| 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. | ||
|
Comment on lines
54
to
61
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π dbus SessionBus error is logged but not returned/wrapped, then execution continues with a nil/invalid conn In trayIconExists() (orbit/cmd/desktop/desktop_linux.go), added π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,7 +163,7 @@ func GetProcessesByName(name string) ([]*gopsutil_process.Process, error) { | |
|
|
||
| // sanity check on returned snapshot handle | ||
| if snapshot == windows.InvalidHandle { | ||
| return nil, errors.New("the snapshot returned returned by CreateToolhelp32Snapshot is invalid") | ||
| return nil, errors.New("the snapshot returned by CreateToolhelp32Snapshot is invalid") | ||
| } | ||
| // Closing the handle to avoid handle leaks. | ||
| defer windows.CloseHandle(snapshot) //nolint:errcheck | ||
|
Comment on lines
163
to
169
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΅ Duplicated word 'returned returned' in error message In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
|
|
@@ -322,7 +322,7 @@ func hardwareGetSMBiosUUID() (string, error) { | |
| // UUID sanity check | ||
| isValidUUID, err := isValidUUID(uuidBytes) | ||
| if err != nil { | ||
| return "", fmt.Errorf("%v", err) | ||
| return "", fmt.Errorf("%w", err) | ||
| } | ||
|
|
||
| if !isValidUUID { | ||
|
Comment on lines
322
to
328
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π fmt.Errorf wrapping error already includes the underlying error via %v inside a generic wrapper, losing %w chain In π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,7 +92,7 @@ func (rw *ReadWriter) SetRemoteUpdateFunc(f remoteUpdaterFunc) { | |
| func (rw *ReadWriter) Write(id string) error { | ||
| if rw.remoteUpdate != nil { | ||
| if err := rw.remoteUpdate(id); err != nil { | ||
| return err | ||
| return fmt.Errorf("remote update of token: %w", err) | ||
| } | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π os.WriteFile error in orbit token ReadWriter.Write is wrapped but remoteUpdate error is not In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,7 +152,7 @@ func (r *ExtensionRunner) Run(config *fleet.OrbitConfig) error { | |
| } | ||
| return nil | ||
| default: | ||
| return fmt.Errorf("stat file: %s", extensionAutoLoadFile) | ||
| return fmt.Errorf("stat file %s: %w", extensionAutoLoadFile, err) | ||
| } | ||
| } | ||
|
|
||
|
Comment on lines
152
to
158
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π readFlagFile call-site wraps errors, but writeFlagFile bare-passes underlying WriteFile error without additional context beyond function name repeat In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -372,7 +372,10 @@ func (r *Runner) updateTarget(target string) error { | |
| } | ||
|
|
||
| func (r *Runner) Interrupt(err error) { | ||
| r.cancel <- struct{}{} | ||
| select { | ||
| case r.cancel <- struct{}{}: | ||
| default: | ||
| } | ||
| } | ||
|
|
||
| // compareVersion compares the old and new versions of a binary and prints the appropriate message. | ||
|
Comment on lines
372
to
381
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Interrupt() drops potential panic on closed/full cancel channel without any guard Changed (Automatically downgraded: no change in this fix lands near this finding's line β verify whether it was actually addressed.) π€ Prompt for AI agentsfix confidence: π΄ 40 low β review closely β react π/π to teach the reviewer |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,7 +125,7 @@ CREATE TABLE IF NOT EXISTS host_mdm_apple_declarations ( | |
| ) | ||
| `) | ||
| if err != nil { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Migration error creating host_mdm_apple_declarations table has a typo but is otherwise correctly wrapped In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| return fmt.Errorf("creatign host_mdm_apple_declarations table %w", err) | ||
| return fmt.Errorf("creating host_mdm_apple_declarations table: %w", err) | ||
| } | ||
|
|
||
| return nil | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ func Up_20240815000001(tx *sql.Tx) error { | |
| // Idempotent migration. | ||
| if !columnExists(tx, "vpp_apps_teams", "self_service") { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Non-lowercase, inconsistent error message wrapping in migration Changed the capitalized error wrap message "Failed to add self_service to vpp_apps_teams: %w" to lowercase "failed to add self_service to vpp_apps_teams: %w" in the Up_20240815000001 function, matching the established lowercase error message convention used by sibling migrations. π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| if _, err := tx.Exec("ALTER TABLE vpp_apps_teams ADD COLUMN self_service bool NOT NULL DEFAULT false"); err != nil { | ||
| return fmt.Errorf("Failed to add self_service to vpp_apps_teams: %w", err) | ||
| return fmt.Errorf("failed to add self_service to vpp_apps_teams: %w", err) | ||
| } | ||
| } | ||
| return nil | ||
|
|
@@ -22,3 +22,4 @@ func Up_20240815000001(tx *sql.Tx) error { | |
| func Down_20240815000001(tx *sql.Tx) error { | ||
| return nil | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ func Up_20250304162702(tx *sql.Tx) error { | |
| UNIQUE KEY idx_ca_config_assets_name (name) | ||
| ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci`) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to create ca_config_assets table: %s", err) | ||
| return fmt.Errorf("failed to create ca_config_assets table: %w", err) | ||
| } | ||
|
|
||
| if !columnExists(tx, "host_mdm_managed_certificates", "not_valid_after") { | ||
|
Comment on lines
22
to
28
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Error wrapped with %s instead of %w loses the error chain in AddCATables migration Changed both π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
|
|
@@ -31,7 +31,7 @@ func Up_20250304162702(tx *sql.Tx) error { | |
| ADD COLUMN not_valid_after DATETIME(6) NULL | ||
| `) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to add not_valid_after column to host_mdm_managed_certificates table: %s", err) | ||
| return fmt.Errorf("failed to add not_valid_after column to host_mdm_managed_certificates table: %w", err) | ||
| } | ||
| } | ||
| return nil | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,7 +68,7 @@ func Up_20250331042354(tx *sql.Tx) error { | |
| `) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π fmt.Errorf without %w breaks error chain in SCIM migration Changed π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
|
|
||
| if err != nil { | ||
| return fmt.Errorf("failed to create scim tables: %s", err) | ||
| return fmt.Errorf("failed to create scim tables: %w", err) | ||
| } | ||
|
|
||
| return nil | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,11 +24,11 @@ func Up_20251124090450(tx *sql.Tx) error { | |
| createdAt := time.Date(2025, 11, 19, 0, 0, 0, 0, time.UTC) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Migration insert error message uses %s instead of %w, discarding error chain for FLEET_VAR_HOST_PLATFORM insert In Up_20251124090450, both π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| stmt, args, err := sqlx.Named(insStmt, map[string]any{"created_at": createdAt}) | ||
| if err != nil { | ||
| return fmt.Errorf("Failed to prepare insert for FLEET_VAR_HOST_PLATFORM: %s", err) | ||
| return fmt.Errorf("failed to prepare insert for FLEET_VAR_HOST_PLATFORM: %w", err) | ||
| } | ||
| _, err = tx.Exec(stmt, args...) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to insert FLEET_VAR_HOST_PLATFORM into fleet_variables: %s", err) | ||
| return fmt.Errorf("failed to insert FLEET_VAR_HOST_PLATFORM into fleet_variables: %w", err) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package tables | |
|
|
||
| import ( | ||
| "database/sql" | ||
| "fmt" | ||
| ) | ||
|
|
||
| func init() { | ||
|
|
@@ -12,7 +13,7 @@ func Up_20260217141240(tx *sql.Tx) error { | |
| // Idempotent migration. Naturally re-runnable (UPDATE/MODIFY/JSON-config only). | ||
| _, err := tx.Exec(`UPDATE labels SET platform = '' WHERE platform NOT IN ('', 'centos', 'darwin', 'windows', 'ubuntu')`) | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("resetting invalid platform on labels: %w", err) | ||
| } | ||
| return nil | ||
| } | ||
|
Comment on lines
13
to
19
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Bare 'return err' in migration without contextual wrapping In Up_20260217141240, wrapped the π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package tables | |
|
|
||
| import ( | ||
| "database/sql" | ||
| "fmt" | ||
| ) | ||
|
|
||
| func init() { | ||
|
Comment on lines
2
to
8
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Migration 20260409153714 returns bare tx.Exec error without wrapping context In Up_20260409153714, added the "fmt" import and wrapped the tx.Exec error with fmt.Errorf("create user_api_endpoints table: %w", err) instead of returning the bare err, matching the style of sibling migrations. π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
|
|
@@ -22,7 +23,7 @@ func Up_20260409153714(tx *sql.Tx) error { | |
| ) | ||
| `) | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("create user_api_endpoints table: %w", err) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ func Up_20260522195225(tx *sql.Tx) error { | |
| ALTER TABLE host_managed_local_account_passwords | ||
| ADD KEY idx_hmlap_auto_rotate_at (auto_rotate_at) | ||
| `); err != nil { | ||
| return fmt.Errorf("adding rotation columns to host_managed_local_account_passwords: %w", err) | ||
| return fmt.Errorf("adding idx_hmlap_auto_rotate_at index to host_managed_local_account_passwords: %w", err) | ||
| } | ||
| } | ||
| return nil | ||
|
Comment on lines
29
to
35
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Duplicate error message on idempotent column-add migration In Up_20260522195225, changed the error message in the second error branch (the ADD KEY / index-add failure) from "adding rotation columns to host_managed_local_account_passwords: %w" to "adding idx_hmlap_auto_rotate_at index to host_managed_local_account_passwords: %w", matching the suggested fix exactly and disambiguating it from the column-add error message above it. π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,7 +65,7 @@ func SuggestAgentOptionsCorrection(err error) error { | |
| if field := GetJSONUnknownField(err); field != nil { | ||
| correctKeyPath, keyErr := FindAgentOptionsKeyPath(*field) | ||
| if keyErr != nil { | ||
| return fmt.Errorf("error parsing generated agent options struct: %w", err) | ||
| return fmt.Errorf("error parsing generated agent options struct: %w", keyErr) | ||
| } | ||
| var keyPathJoined string | ||
| switch pathLen := len(correctKeyPath); { | ||
|
Comment on lines
65
to
71
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π SuggestAgentOptionsCorrection swallows keyErr instead of wrapping it into the returned error chain In SuggestAgentOptionsCorrection (server/fleet/agent_options.go), changed the error wrapping on the FindAgentOptionsKeyPath failure branch from π€ Prompt for AI agentsfix confidence: π’ 97 high β react π/π to teach the reviewer |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,9 +78,13 @@ func (w *pubSubLogWriter) Write(ctx context.Context, logs []json.RawMessage) err | |
| } | ||
|
|
||
| if len(data)+estimateAttributeSize(attributes) > pubsub.MaxPublishRequestBytes { | ||
| logPreview := log | ||
| if len(logPreview) > 100 { | ||
| logPreview = logPreview[:100] | ||
| } | ||
| w.logger.InfoContext(ctx, "dropping log over 10MB PubSub limit", | ||
| "size", len(data), | ||
| "log", string(log[:100])+"...", | ||
| "log", string(logPreview)+"...", | ||
| ) | ||
| continue | ||
| } | ||
|
Comment on lines
78
to
90
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π pubSubLogWriter.Write silently drops oversized messages without wrapping/propagating a warning error In π€ Prompt for AI agentsfix confidence: π’ 92 high β react π/π to teach the reviewer
Comment on lines
78
to
90
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ pubSubLogWriter oversized-log slicing can panic on short log payloads In π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
|
|
@@ -95,6 +99,9 @@ func (w *pubSubLogWriter) Write(ctx context.Context, logs []json.RawMessage) err | |
|
|
||
| // Wait for each message to be pushed to the server | ||
| for _, result := range results { | ||
| if result == nil { | ||
| continue | ||
| } | ||
| _, err := result.Get(ctx) | ||
| if err != nil { | ||
| return ctxerr.Wrap(ctx, err, "pubsub publish") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,7 +106,7 @@ func (s *sesSender) sendMail(ctx context.Context, e fleet.Email, msg []byte) err | |
| SourceArn: &s.sourceArn, | ||
| }) | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("send raw email via ses: %w", err) | ||
| } | ||
| return nil | ||
| } | ||
|
Comment on lines
106
to
112
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π sesSender.sendMail returns bare err without wrapping context In π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,12 +132,12 @@ func GetSignedAPNSCSR(client *http.Client, csr *x509.CertificateRequest) error { | |
|
|
||
| req, err := http.NewRequest(http.MethodPost, u, bytes.NewReader(b)) | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("creating csr signing request for fleetdm api: %w", err) | ||
| } | ||
|
|
||
| resp, err := client.Do(req) | ||
| if err != nil { | ||
| return err | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π GetSignedAPNSCSR returns raw errors from http.NewRequest/client.Do without wrapping In GetSignedAPNSCSR (server/mdm/apple/cert.go), wrapped the bare π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| return fmt.Errorf("sending csr signing request to fleetdm api: %w", err) | ||
| } | ||
| defer resp.Body.Close() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,7 @@ func VerifyHostMDMProfiles(ctx context.Context, ds fleet.ProfileVerificationStor | |
|
|
||
| expectedByProfIdentifier, err := ds.GetHostMDMProfilesExpectedForVerification(ctx, host) | ||
| if err != nil { | ||
| return err | ||
| return ctxerr.Wrap(ctx, err, "getting expected MDM profiles for verification") | ||
| } | ||
|
|
||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π VerifyHostMDMProfiles returns underlying datastore errors unwrapped, losing call context In VerifyHostMDMProfiles, the π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| missing := make([]string, 0, len(expectedByProfIdentifier)) | ||
|
|
@@ -85,7 +85,7 @@ func VerifyHostMDMProfiles(ctx context.Context, ds fleet.ProfileVerificationStor | |
| if len(missing) > 0 { | ||
| counts, err := ds.GetHostMDMProfilesRetryCounts(ctx, host) | ||
| if err != nil { | ||
| return err | ||
| return ctxerr.Wrap(ctx, err, "getting host MDM profile retry counts") | ||
| } | ||
| retriesByProfileIdentifier := make(map[string]uint, len(counts)) | ||
| for _, r := range counts { | ||
|
Comment on lines
85
to
91
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Retry-count lookup error returned bare, without ctxerr wrap, in VerifyHostMDMProfiles In VerifyHostMDMProfiles, the π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
|
|
@@ -174,3 +174,4 @@ func HandleHostMDMProfileInstallResult(ctx context.Context, ds fleet.ProfileVeri | |
| } | ||
| return nil | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| package commonmdm | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "net/url" | ||
| "path" | ||
| ) | ||
|
|
@@ -10,7 +11,7 @@ import ( | |
| func ResolveURL(serverURL, relPath string, cleanQuery bool) (string, error) { | ||
| u, err := url.Parse(serverURL) | ||
| if err != nil { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π ResolveURL returns url.Parse error unwrapped, losing call-boundary context In ResolveURL, wrapped the π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| return "", err | ||
| return "", fmt.Errorf("parsing server URL: %w", err) | ||
| } | ||
| u.Path = path.Join(u.Path, relPath) | ||
| if cleanQuery { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,7 +234,7 @@ func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { | |
|
|
||
| session, err = DoAuth(t.client, sessionReq, tokens) | ||
| if err != nil { | ||
| return nil, err | ||
| return nil, fmt.Errorf("transport: performing dep auth: %w", err) | ||
| } | ||
|
|
||
| // save our session token for use by following requests | ||
|
Comment on lines
234
to
240
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Bare error return without wrapping in SetSessionToken call site In π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
|
|
@@ -277,3 +277,4 @@ func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { | |
|
|
||
| return resp, nil | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,8 +88,7 @@ func run(cfg runCfg) error { | |
|
|
||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π os.Exit called immediately after printing error instead of returning wrapped error from loadOrMakeCSR failure In run(), replaced the π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| csr, err := loadOrMakeCSR(cfg.csrPath, opts) | ||
| if err != nil { | ||
| fmt.Println(err) | ||
| os.Exit(1) | ||
| return fmt.Errorf("load or make CSR: %w", err) | ||
| } | ||
|
|
||
| var self *x509.Certificate | ||
|
|
@@ -256,7 +255,7 @@ func validateFlags(keyPath, serverURL, caFingerprint string, useKeyEnciphermentS | |
| } | ||
| _, err := url.Parse(serverURL) | ||
| if err != nil { | ||
| return fmt.Errorf("invalid server-url flag parameter %s", err) | ||
| return fmt.Errorf("invalid server-url flag parameter: %w", err) | ||
| } | ||
| if caFingerprint != "" && useKeyEnciphermentSelector { | ||
| return errors.New("ca-fingerprint and key-encipherment-selector can't be used at the same time") | ||
|
Comment on lines
255
to
261
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Bare fmt.Errorf without %w wrapping loses causal chain in scepclient.go In validateFlags(), changed π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,13 +33,13 @@ func (e *errWithStatus) StatusCode() int { | |
| func PostJSONWithTimeout(ctx context.Context, url string, v any, logger *slog.Logger) error { | ||
| jsonBytes, err := json.Marshal(v) | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("marshal json body: %w", err) | ||
| } | ||
|
|
||
| client := fleethttp.NewClient(fleethttp.WithTimeout(30 * time.Second)) | ||
| req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewBuffer(jsonBytes)) | ||
| if err != nil { | ||
| return err | ||
| return fmt.Errorf("build POST request: %w", err) | ||
| } | ||
|
|
||
| req.Header.Set("Content-Type", "application/json") | ||
|
Comment on lines
33
to
45
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π json.Marshal error returned bare in PostJSONWithTimeout In PostJSONWithTimeout, wrapped the bare π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,10 +42,6 @@ func (c *Client) Setup(email, name, password, org string) (string, error) { | |
| ) | ||
| } | ||
|
|
||
| if response.StatusCode != http.StatusOK { | ||
| return "", fmt.Errorf("setup got HTTP %d, expected 200", response.StatusCode) | ||
| } | ||
|
|
||
| var responseBody setupResponse | ||
| err = json.NewDecoder(response.Body).Decode(&responseBody) | ||
| if err != nil { | ||
|
Comment on lines
42
to
47
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Redundant status-code check duplicated immediately after the first check in Setup Removed the redundant, unreachable second π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
|
|
@@ -58,3 +54,4 @@ func (c *Client) Setup(email, name, password, org string) (string, error) { | |
|
|
||
| return *responseBody.Token, nil | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,7 @@ func (tr *OpenframeTokenRefresher) Start() error { | |
| log.Info().Msg("Scheduling token refresh job") | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Cron start error returned without call-boundary context beyond the static string In Start(), changed the error wrapping from π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| _, err := tr.cron.AddFunc("*/5 * * * * *", tr.refreshToken) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to schedule token refresh job: %v", err) | ||
| return fmt.Errorf("failed to schedule token refresh job: %w", err) | ||
| } | ||
| tr.cron.Start() | ||
| log.Info().Msg("Token refresh job started") | ||
|
|
@@ -73,4 +73,4 @@ func (tr *OpenframeTokenRefresher) refreshToken() { | |
|
|
||
| tr.authorizationManager.UpdateToken(token) | ||
| log.Info().Msg("Openframe token refreshed") | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
𦩠π downloadLatestGitHubAsset double-wraps the same error context redundantly
In
downloadLatestGitHubAsset, the status-code error branch no longer wraps with the redundant"get last mod start date: %w"prefix (which duplicated the same context already applied to theclient.Geterror). It now returnsfmt.Errorf("unexpected status code %d fetching %s", resp.StatusCode, fileName)directly, exactly matching the suggested fix, eliminating the doubled message.π€ Prompt for AI agents
fix confidence: π’ 90 high β react π/π to teach the reviewer