Awesome Reviewers

Reviewer · Error Handling

Distinguish errors from expected states

Before logging or propagating an error, verify whether the condition actually represents a failure or is simply a normal/expected state (an unset optional field, an absent resource, a "not found" response, etc.). Guard parsing or validation logic with explicit checks so that valid configurations don't trigger spurious error logs, e.g. only parse optional...

Instruction

Before logging or propagating an error, verify whether the condition actually represents a failure or is simply a normal/expected state (an unset optional field, an absent resource, a “not found” response, etc.). Guard parsing or validation logic with explicit checks so that valid configurations don’t trigger spurious error logs, e.g. only parse optional PEM data when it is actually present:

if len(entry.OcspCaCertificates) > 0 {
    certs, err := certutil.ParseCertsPEM([]byte(entry.OcspCaCertificates))
    ...
}

Similarly, when an external call can legitimately return “not found” (such as a 404 from a blob store during initial lock creation), explicitly detect that status and treat it as a normal case rather than failing the whole operation — don’t assume a non-nil response/error always indicates success/failure without checking the actual status code or payload. When inspecting results from a request, confirm the response object itself is valid (non-nil) before relying on it, and prefer early returns on error paths instead of nested conditionals for clarity. When surfacing error messages to users, unwrap layered errors to extract the meaningful underlying cause (e.g., an enterprise-only feature message) rather than exposing only the generic outer wrapper text. Applying these checks consistently prevents false alarms in logs, avoids deadlocks or failed operations on expected edge cases, and ensures users see actionable, accurate error messages.