From bddd9df1fce3e0f92f5837bb37369902933456b8 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Thu, 10 Oct 2024 13:29:36 -0400 Subject: [PATCH] limit exception more tightly to seed rules --- app/client/aclui/AccessRules.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/client/aclui/AccessRules.ts b/app/client/aclui/AccessRules.ts index 9b087255..edc1702c 100644 --- a/app/client/aclui/AccessRules.ts +++ b/app/client/aclui/AccessRules.ts @@ -1084,6 +1084,16 @@ abstract class ObsRuleSet extends Disposable { public getCustomRules(): ObsRulePart[] { return this._body.get().filter(rule => !rule.isBuiltInOrEmpty()); } + + /** + * If the set applies to a special column, return its name. + */ + public getSpecialColumn(): string|undefined { + if (this._ruleSet?.tableId === SPECIAL_RULES_TABLE_ID && + this._ruleSet.colIds.length === 1) { + return this._ruleSet.colIds[0]; + } + } } class ColumnObsRuleSet extends ObsRuleSet { @@ -1817,9 +1827,12 @@ class ObsRulePart extends Disposable { private _warnInvalidColIds(colIds?: string[]) { if (!colIds || !colIds.length) { return false; } const allValid = new Set(this._ruleSet.getValidColIds()); - // Don't check column validity if we don't have any. - // For example, the seed rule has no columns. - if (allValid.size === 0) { return false; } + const specialColumn = this._ruleSet.getSpecialColumn(); + if (specialColumn === 'SeedRule') { + // We allow seed rules to refer to columns without checking + // them (until the seed rules are used). + return false; + } const invalid = colIds.filter(c => !allValid.has(c)); if (invalid.length > 0) { return `Invalid columns: ${invalid.join(', ')}`;