fix(api-service): Intercom hash null data error fixes NV-7061#9847
fix(api-service): Intercom hash null data error fixes NV-7061#9847
Conversation
- Add null/undefined validation to createHash function in hmac.ts - Update createContextHash to return string | null - Add null checks in Intercom hash assignment in login, register, and get-profile - Add validation in OAuth state generation for Slack and MS Teams - Handle null gracefully in conditions-filter buildHmac Fixes NV-7061 - TypeError when data argument is null in Hmac.update Co-authored-by: dima <dima@novu.co>
|
Cursor Agent can help with this pull request. Just |
✅ Deploy Preview for dashboard-v2-novu-staging canceled.
|
Co-authored-by: dima <dima@novu.co>
WalkthroughChanges add defensive checks and nullability across authentication, integration, and webhook code paths. HMAC utilities and related methods now return 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@libs/application-generic/src/usecases/conditions-filter/conditions-filter.usecase.ts`:
- Line 281: The current return uses
createHash(decryptApiKey(environment.apiKeys[0].key), command.environmentId) ||
'' which silently converts a null HMAC into an empty string; update the logic in
the function containing this return (where decryptApiKey, environment.apiKeys,
and createHash are used) to avoid the || '' fallback: if createHash returns null
or if decryptApiKey or command.environmentId are falsy, either throw a
descriptive error (e.g., "Unable to generate nv-hmac-256: missing api key or
environmentId") or return a value that signals omission of the header upstream
so you do not send an empty nv-hmac-256; ensure the change is applied where the
header is set so callers can handle the absent signature.
libs/application-generic/src/usecases/conditions-filter/conditions-filter.usecase.ts
Outdated
Show resolved
Hide resolved
- Update buildHmac to return string | null instead of using || '' fallback - Validate apiKey and environmentId before calling createHash - Update getWebhookResponse to only include nv-hmac-256 header when hmac is valid - Return null in test environment for consistency Co-authored-by: dima <dima@novu.co>
What changed? Why was the change needed?
This PR resolves
NV-7061, aTypeErroroccurring inHmac.updatewhen thecreateHashfunction receivednullorundefinedinputs, primarily affecting Intercom hash generation.The
createHashandcreateContextHashfunctions inlibs/application-generic/src/utils/hmac.tswere updated to:keyorvalueToHashare null/undefined.nullinstead of throwing aTypeErrorin such cases.Corresponding callers of
createHashwere updated to handle thenullreturn value gracefully:createHashreturnsnull.BadRequestExceptionis thrown ifcreateHashfails to generate a signature, preventing malformed state tokens.createHashreturnsnull.Screenshots
N/A
Expand for optional sections
Related enterprise PR
N/A
Special notes for your reviewer
The changes ensure that the application handles invalid hash inputs gracefully without crashing, improving robustness.
Linear Issue: NV-7061