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