Skip to content

Commit 94e4ac0

Browse files
committed
fix: use omit() to properly remove conditionals from ReadActionConfig
The .extend() method in Zod merges fields rather than replacing them. When ActionConfigBase has conditionals defined, extending with conditionals: z.never() creates a conflict. Using .omit({conditionals: true}) first removes the field completely, then .extend() adds only the fields we want without the conditionals field. This ensures READ actions truly cannot have conditionals, fixing the validation error: 'expected never, received array' at path actions[0].conditionals
1 parent ff488b3 commit 94e4ac0

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

packages/commons/src/conditionals/validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ function isActionConditionMet(
287287
context: ValidatorContext,
288288
conditionalType: ConditionalType
289289
) {
290-
if (!actionConfig.conditionals) {
290+
if (!('conditionals' in actionConfig) || !actionConfig.conditionals) {
291291
return true
292292
}
293293

packages/commons/src/events/ActionConfig.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,11 @@ const DeclarationActionBase = ActionConfigBase.extend({
5353
deduplication: DeduplicationConfig.optional()
5454
})
5555

56-
const ReadActionConfig = ActionConfigBase.extend({
56+
const ReadActionConfig = ActionConfigBase.omit({ conditionals: true }).extend({
5757
type: z.literal(ActionType.READ),
5858
review: DeclarationReviewConfig.describe(
5959
'Configuration of the review page for read-only view.'
60-
),
61-
conditionals: z
62-
.never()
63-
.optional()
64-
.describe('Read-action can not be disabled or hidden with conditionals.')
60+
)
6561
})
6662

6763
const DeclareConfig = DeclarationActionBase.extend({

0 commit comments

Comments
 (0)