Review Agent PRs That Hide Missing Data With Optional Chaining
Описание и применение
Агенты заменяют проверки обязательных полей опциональной цепочкой, скрывая ошибки и возвращая успешные ответы. Внедрите явную валидацию, откатите скрытые значения и добавьте тесты на отсутствие данных.
Задача
Agents replace required field checks with optional chaining, silently swallowing missing data and returning success responses, leading to contract violations and hidden failures.
Результат
Reverted silent defaults, restored validation, added failing tests for missing data, and prevented sensitive logs, ensuring contract integrity and reliable error handling.
Рабочий процесс
- 1. Review PR diff for optional chaining usage on required fields.
- 2. Identify silent defaults (e.g., ?? "", ?? 0).
- 3. Check for HTTP 200 responses with skipped:true instead of 4xx.
- 4. Verify absence of schema validation or guard clauses.
- 5. Revert silent defaults and restore explicit checks.
- 6. Add tests for missing required fields to fail with 400.
- 7. Ensure zero cents is a valid charge and missing cents triggers 400.
- 8. Block logs that expose sensitive request bodies.
Доказательства
Optional chaining removes the stack trace. Reviewers often praise the quieter error logs.
Revert silent defaults on identifiers. Revert ?? 0 on money fields.
- Дата записи: 2026-09-19T06:30:34.894Z