Skip to content

Conversation

@Attacktive
Copy link

The evaluateJob function was proceeding to process job events even when MachineGet was kind of unsuccessful; the exit code 404 alone is covered.

changes:

  • added an explicit return when MachineGet returns an error (non-404).
  • added a check if machine is nil even if no error is returned

} else {
log.WithError(err).Errorf("failed to get machine %s: %v", job.MachineID.String, err)
}
log.WithError(err).Errorf("failed to get machine %s: %v", job.MachineID.String, err)
Copy link
Author

Choose a reason for hiding this comment

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

I'm not 100% sure if it deliberately proceeds in non-404 cases, so let me know if it does. 🙂

@Attacktive Attacktive marked this pull request as ready for review December 30, 2025 08:12
@davissp14 davissp14 requested a review from Copilot January 16, 2026 19:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a potential nil pointer dereference panic in the evaluateJob function by ensuring proper error handling when MachineGet fails and by adding a defensive nil check even when no error is returned.

Changes:

  • Added early return when MachineGet returns a non-404 error to prevent further processing
  • Added explicit nil check for the machine object before accessing its properties
  • Restructured error handling logic to use if-else for better control flow
Comments suppressed due to low confidence (1)

internal/cron/monitor.go:79

  • The error is being logged with both WithError(err) and %v formatting of the same error, which results in duplicate error information in the log output. Remove the : %v and err parameter from the format string to avoid redundancy.
				log.WithError(err).Errorf("failed to get machine %s: %v", job.MachineID.String, err)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
return nil
} else {
log.WithError(err).Errorf("failed to get machine %s: %v", job.MachineID.String, err)
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The error is being logged with both WithError(err) and %v formatting of the same error, which results in duplicate error information in the log output. Remove the : %v and err parameter from the format string to avoid redundancy.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant