{"record":{"id":"a5181519fdefb993","repo":"twentyhq/twenty","slug":"failed-to-sync-discard-draft-workflow-command-me","errorCode":null,"errorMessage":"Failed to sync \"Discard Draft\" workflow command menu item availability expression for workspace ${workspaceId}","messagePattern":"Failed to sync \"Discard Draft\" workflow command menu item availability expression for workspace (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/2-28/2-28-workspace-command-1785858486000-sync-discard-draft-workflow-availability-expression.command.ts","lineNumber":86,"sourceCode":"          allFlatEntityOperationByMetadataName: {\n            commandMenuItem: {\n              flatEntityToCreate: [],\n              flatEntityToDelete: [],\n              flatEntityToUpdate: commandMenuItemsToUpdate,\n            },\n          },\n          workspaceId,\n          applicationUniversalIdentifier:\n            twentyStandardFlatApplication.universalIdentifier,\n        },\n      );\n\n    if (validateAndBuildResult.status === 'fail') {\n      this.logger.error(\n        `Failed to sync \"Discard Draft\" workflow command menu item availability expression:\\n${JSON.stringify(validateAndBuildResult, null, 2)}`,\n      );\n\n      throw new Error(\n        `Failed to sync \"Discard Draft\" workflow command menu item availability expression for workspace ${workspaceId}`,\n      );\n    }\n\n    this.logger.log(\n      `Successfully synced \"Discard Draft\" workflow command menu item availability expression for workspace ${workspaceId}`,\n    );\n  }\n}\n","sourceCodeStart":68,"sourceCodeEnd":96,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/2-28/2-28-workspace-command-1785858486000-sync-discard-draft-workflow-availability-expression.command.ts#L68-L96","documentation":"Thrown by the 2.28 command that syncs the 'Discard Draft' workflow command menu item's availability expression. It updates the command menu item via validateBuildAndRunLegacyWorkspaceMigration; on status === 'fail' it logs the report and throws. Failure is in the command-menu-item update validation.","triggerScenarios":"The 'Discard Draft' command menu item universalIdentifier does not exist in the workspace (so the update targets nothing); the availability expression string fails the expression validator (syntax/unknown reference); the twentyStandardFlatApplication linkage is broken for the workspace.","commonSituations":"Workspace on a version that never had the Discard Draft command menu item seeded; the expression references a field/object that was since renamed; cross-version upgrade where an intermediate command that creates the item was skipped.","solutions":["Read the logged JSON report to see whether the failure is a missing-entity or an expression-validation error.","If the command menu item is missing, ensure the upgrade command that seeds it (earlier in the version chain) ran for the workspace.","If the expression is invalid, correct or clear the stored availability expression for that item, then re-run the 2.28 command."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm the target command menu item exists before running the 2.28 sync:\nconst item = flatCommandMenuItemMaps.byUniversalIdentifier[DISCARD_DRAFT_UI];\nif (!isDefined(item)) { /* run the command that seeds it first */ }","typeGuard":null,"tryCatchPattern":"try {\n  await command.runOnWorkspace({ workspaceId, options });\n} catch (e) {\n  logger.error({ workspaceId, err: e.message }, 'Discard Draft availability sync failed');\n}","preventionTips":["Run prerequisite upgrade commands that seed command menu items before availability-expression syncs.","Validate availability expressions against the current object/field identifiers before applying."],"tags":["migration","upgrade-command","validate-and-build","workspace","command-menu-item","availability-expression","workflow"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}