Awesome Reviewers

Reviewer · Null Handling

Guard undefined and null explicitly

Treat the possibility of missing data as a first-class concern instead of assuming happy-path presence. This applies to external responses, optional schema fields, array indexing, and refactored data shapes alike:

Instruction

Treat the possibility of missing data as a first-class concern instead of assuming happy-path presence. This applies to external responses, optional schema fields, array indexing, and refactored data shapes alike:

  • Validate external/untrusted responses explicitly before trusting them. Reject or coerce to unknown any payload missing required fields (e.g. an id or a boolean revoked) instead of letting null/absent fields silently flow through as valid data.
  • When traversing nested or dotted paths that may be partially present, don’t stop at the first prefix that happens to exist — keep trying remaining splits so a shorter existing-but-wrong-shaped branch doesn’t mask the real value and produce a false undefined.
  • Bounds-check array access before indexing, especially when the result feeds a callback or type that is declared non-optional. Even if a guard is currently unreachable (e.g. UI buttons disabled at the edges), add the check so the code stays correct if that invariant changes:
    const prev = currentIndex > 0 ? displayedRows[currentIndex - 1] : undefined;
    const next = currentIndex < total - 1 ? displayedRows[currentIndex + 1] : undefined;
    
  • When making one field optional because it’s part of an either/or relationship with another (e.g. connectorId vs recipients as alternate delivery channels), audit and update the related field’s optionality too — don’t leave one side still required, forcing callers to pass empty placeholders like recipients: [].
  • When a refactor removes or relocates a field that downstream code still reads directly (e.g. step.output after output moved to the IO stream), update every consumer to fetch the value through the new source instead of silently getting undefined/empty results. Add or update tests that exercise the no-output path so regressions are caught.

The common rule: at every boundary where a value can legitimately be missing, decide and enforce explicit behavior (reject, fall back, or fetch from the right source) rather than letting undefined/null pass through implicitly and produce silently wrong results.</description> </invoke>