Conversation
✅ Deploy Preview for dashboard-v2-novu-staging canceled.
|
| 'Novu-Client-Version': DEFAULT_CLIENT_VERSION, | ||
| 'Content-Type': 'application/json', | ||
| 'User-Agent': userAgent, | ||
| 'User-Agent': userAgent, // Deprecated: Doesn't work in browsers, kept for backward compatibility |
There was a problem hiding this comment.
User-Agent is not a reliable header, its being stripped therefore I couldn't use it to check the @novu/js version, so I introduced new one.
There was a problem hiding this comment.
Will do that in separate PR.
WalkthroughThe changes introduce client version tracking through a new HTTP header 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
@novu/js
@novu/nextjs
novu
@novu/react
@novu/react-native
commit: |
What changed? Why was the change needed?
Problem
Context preferences require
contextKeysin both JWT and subscription identifier, but old clients only include them in JWT.In more detail - https://linear.app/novu/issue/NV-7072/context-preferences-subscription-identifier-compatibility-issue
Why Context Must Be in the Identifier
tk_updates:si_user123:ctx_project:atk_updates:si_user123:ctx_project:bThe Mismatch
sequenceDiagram participant Old Client participant API participant Database Note over Old Client: @novu/js < 3.13.0 Old Client->>API: POST /subscriptions<br/>identifier: "tk_updates:si_user123"<br/>JWT contains: contextKeys=["project:a"] API->>API: Sees contextKeys in JWT<br/>Adds :ctx_ to identifier API->>Database: Store subscription<br/>identifier: "tk_updates:si_user123:ctx_project:a" Note over Old Client: Later: tries to fetch subscription Old Client->>API: GET /subscriptions/tk_updates:si_user123<br/>(auto-generated, no :ctx_) API->>Database: Find by identifier:<br/>"tk_updates:si_user123" Database-->>API: ❌ Not found API-->>Old Client: 404Root cause: Old client generates identifier without
:ctx_, but server adds it → permanent mismatch.Solution
Context Compatibility Interceptor detects old clients and strips
contextKeysfrom JWT before processing:sequenceDiagram participant Old Client participant Interceptor participant API participant Database Old Client->>Interceptor: POST /subscriptions<br/>No Novu-Client-Version header<br/>JWT: contextKeys=["project:a"] Interceptor->>Interceptor: Check header<br/>Missing → old client Interceptor->>Interceptor: Strip contextKeys from session Interceptor->>API: Continue request<br/>contextKeys=undefined API->>Database: Store subscription<br/>identifier: "tk_updates:si_user123"<br/>(no :ctx_) Note over Old Client: Later: fetch works! Old Client->>API: GET /subscriptions/tk_updates:si_user123 API->>Database: Find: "tk_updates:si_user123" Database-->>API: ✅ Found API-->>Old Client: 200 OKChanges
Novu-Client-VersionheadercontextKeysfor clients < 3.13.0 or missing headerDeployment
@novu/js@3.13.0