Standardize isDefined usage for metadata version assertions (#11829)

# Introduction
`!value` is risky as `!falsy` would return `true`
This commit is contained in:
Paul Rastoin
2025-05-02 11:07:12 +02:00
committed by GitHub
parent 9df4778954
commit 3e1b4ace37
5 changed files with 10 additions and 6 deletions

View File

@ -307,7 +307,7 @@ export class WorkspaceDatasourceFactory {
let latestWorkspaceMetadataVersion =
await this.workspaceCacheStorageService.getMetadataVersion(workspaceId);
if (latestWorkspaceMetadataVersion === undefined) {
if (!isDefined(latestWorkspaceMetadataVersion)) {
if (shouldFailIfMetadataNotFound) {
throw new TwentyORMException(
`Metadata version not found for workspace ${workspaceId}`,
@ -325,7 +325,7 @@ export class WorkspaceDatasourceFactory {
}
}
if (!latestWorkspaceMetadataVersion) {
if (!isDefined(latestWorkspaceMetadataVersion)) {
throw new TwentyORMException(
`Metadata version not found after recompute for workspace ${workspaceId}`,
TwentyORMExceptionCode.METADATA_VERSION_NOT_FOUND,