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:
Thomas Trompette
2026-03-24 18:13:31 +01:00
committed by GitHub
parent cac92bffe3
commit c94aa7316a
2 changed files with 3 additions and 3 deletions
@@ -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 }),
@@ -291,8 +291,8 @@ export const useGraphQLErrorHandlerHook = <
}
if (
!frontEndAppVersion ||
!backendAppVersion ||
!isDefined(frontEndAppVersion) ||
!isDefined(backendAppVersion) ||
!semver.valid(frontEndAppVersion) ||
!semver.valid(backendAppVersion)
) {