fix(webhooks): accept null leaves in settings GET response#39
Conversation
GHIN's GET /webhook_settings returns every event key on every top-level field with `null` as the "unregistered" sentinel, not an omitted key. The previous schema rejected null, causing parse failures and incorrect `ensureRegistered` change detection. Split the inner schema into response (accepts null + undefined) and request (optional only) variants so PATCH bodies still steer callers toward `''` for clearing a URL.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR extends webhook settings handling to accept ChangesWebhook Null Value Support
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #39 +/- ##
=======================================
Coverage ? 95.73%
=======================================
Files ? 53
Lines ? 2488
Branches ? 423
=======================================
Hits ? 2382
Misses ? 106
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
GHIN's webhook settings GET response always includes every event key under
webhook_url,webhook_data_type, andwebhook_enabled, usingnullas the "unregistered" sentinel rather than omitting the key. This was causingschemaWebhookSettingsto fail Zod parsing andensureRegisteredto misreport state. The response schema now acceptsstring | null | undefinedper leaf, while PATCH bodies retain the stricter "optional, no null" shape (use''to clear a URL).Changes
partialEventMapResponse(acceptsnull) andpartialEventMapRequest(rejectsnull) so GET and PATCH schemas are intentionally asymmetric.normalizeWebhookUrlanddescribeLeafto acceptnulland treat it the same asundefined/(not set).Testing
bun run test:run— 285 tests pass./scripts/code-quality.sh— cleanThe new test mocks GHIN returning
nullfor every leaf and assertsensureRegisteredPATCHes with a(not set)reason.Summary by CodeRabbit