send X-Schema-Version header when metadataVersion is 0 (#18924)
Fixes https://github.com/twentyhq/twenty/issues/13103 Newly created workspaces start with metadataVersion = 0. The truthy check this.currentWorkspace?.metadataVersion && {…} treated 0 as falsy, so the X-Schema-Version header was never sent. Without this header, the backend's schema mismatch detection is bypassed and raw validation errors leak to Sentry. Replaced with isDefined() check. Also replaced bare negation checks with isDefined() in the backend validation hook for consistency.
This commit is contained in:
@@ -132,7 +132,7 @@ export class ApolloFactory implements ApolloManager {
|
||||
...optionHeaders,
|
||||
authorization: token ? `Bearer ${token}` : '',
|
||||
'x-locale': locale,
|
||||
...(this.currentWorkspace?.metadataVersion && {
|
||||
...(isDefined(this.currentWorkspace?.metadataVersion) && {
|
||||
'X-Schema-Version': `${this.currentWorkspace.metadataVersion}`,
|
||||
}),
|
||||
...(this.appVersion && { 'X-App-Version': this.appVersion }),
|
||||
|
||||
+2
-2
@@ -291,8 +291,8 @@ export const useGraphQLErrorHandlerHook = <
|
||||
}
|
||||
|
||||
if (
|
||||
!frontEndAppVersion ||
|
||||
!backendAppVersion ||
|
||||
!isDefined(frontEndAppVersion) ||
|
||||
!isDefined(backendAppVersion) ||
|
||||
!semver.valid(frontEndAppVersion) ||
|
||||
!semver.valid(backendAppVersion)
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user