From 9e5857cd9b3496bfce00b75ecfeaa3178bea6378 Mon Sep 17 00:00:00 2001 From: wendrul Date: Wed, 4 Mar 2026 17:45:44 +0100 Subject: [PATCH] backwards compat: add a flag to enable theis behaviour defaults to enabled on wmill init, but preserves old behaviour if wmill.yaml already present without the flag. Upgrade is also simple --- cli/src/commands/sync/sync.ts | 49 +++++++++++++++++++---------------- cli/src/core/conf.ts | 3 +++ 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/cli/src/commands/sync/sync.ts b/cli/src/commands/sync/sync.ts index b1cd1690c0..c80cce5caf 100644 --- a/cli/src/commands/sync/sync.ts +++ b/cli/src/commands/sync/sync.ts @@ -2571,30 +2571,33 @@ export async function push( return; } - // Build permissioned_as context - const user = await wmill.whoami({ workspace: workspace.workspaceId }); - const userIsAdminOrDeployer = - user.is_admin || (user.groups ?? []).includes("wm_deployers"); - log.debug(`permissioned_as: user=${user.email}, is_admin=${user.is_admin}, groups=${JSON.stringify(user.groups)}, isAdminOrDeployer=${userIsAdminOrDeployer}`); - const validatedRules = validatePermissionedAsRules( - opts.defaultPermissionedAs, - "wmill.yaml" - ); - log.debug(`permissioned_as: ${validatedRules.length} rules loaded`); - const permissionedAsContext: PermissionedAsContext = { - rules: validatedRules, - emailToUsernameCache: new Map(), - userIsAdminOrDeployer, - }; + // Build permissioned_as context (only when respectVirtualUserPermissions is enabled) + let permissionedAsContext: PermissionedAsContext | undefined = undefined; + if (opts.respectVirtualUserPermissions) { + const user = await wmill.whoami({ workspace: workspace.workspaceId }); + const userIsAdminOrDeployer = + user.is_admin || (user.groups ?? []).includes("wm_deployers"); + log.debug(`permissioned_as: user=${user.email}, is_admin=${user.is_admin}, groups=${JSON.stringify(user.groups)}, isAdminOrDeployer=${userIsAdminOrDeployer}`); + const validatedRules = validatePermissionedAsRules( + opts.defaultPermissionedAs, + "wmill.yaml" + ); + log.debug(`permissioned_as: ${validatedRules.length} rules loaded`); + permissionedAsContext = { + rules: validatedRules, + emailToUsernameCache: new Map(), + userIsAdminOrDeployer, + }; - // Pre-check: warn non-admin/non-deployer users about permissioned_as changes - await preCheckPermissionedAs( - changes, - user.email, - userIsAdminOrDeployer, - opts.acceptOverridingPermissionedAsWithSelf ?? false, - !!process.stdin.isTTY - ); + // Pre-check: warn non-admin/non-deployer users about permissioned_as changes + await preCheckPermissionedAs( + changes, + user.email, + userIsAdminOrDeployer, + opts.acceptOverridingPermissionedAsWithSelf ?? false, + !!process.stdin.isTTY + ); + } if ( !opts.yes && diff --git a/cli/src/core/conf.ts b/cli/src/core/conf.ts index 67d72295e6..cff71fefd6 100644 --- a/cli/src/core/conf.ts +++ b/cli/src/core/conf.ts @@ -104,6 +104,7 @@ export interface SyncOptions { lint?: boolean; locksRequired?: boolean; defaultPermissionedAs?: PermissionedAsRule[]; + respectVirtualUserPermissions?: boolean; } export interface Codebase { @@ -352,6 +353,7 @@ export const DEFAULT_SYNC_OPTIONS: Readonly< | "includeSettings" | "includeKey" | "nonDottedPaths" + | "respectVirtualUserPermissions" > > > = { @@ -375,6 +377,7 @@ export const DEFAULT_SYNC_OPTIONS: Readonly< includeKey: false, skipWorkspaceDependencies: false, nonDottedPaths: false, + respectVirtualUserPermissions: true, } as const; export async function mergeConfigWithConfigFile(