Skip to content

fix: map unified allow/block to valid Vercel actions instead of passing through - #280

Merged
gfargo merged 1 commit into
mainfrom
fix/vercel-allow-block-action-mapping
Aug 25, 2026
Merged

fix: map unified allow/block to valid Vercel actions instead of passing through#280
gfargo merged 1 commit into
mainfrom
fix/vercel-allow-block-action-mapping

Conversation

@gfargo

@gfargo gfargo commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Fixes #262

Summary

unifiedToVercel used rule.action.type directly with no mapping at all — so a rule with action: {type: 'allow'} or {type: 'block'} passed doorman's own local validation (against the wider 8-value unified ActionType) and was dispatched to Vercel's real API carrying a mitigate.action value Vercel's own native schema (log, deny, challenge, bypass, rate_limit, redirect — 6 values, no allow/block) says is invalid.

Added VercelActionType (types/vercel.ts), Vercel's actual native action vocabulary — previously VercelMitigationAction.action reused the wider unified ActionType directly, so TypeScript never caught the mismatch either. This matches the pattern CloudflareAction/FastlyRequestActionType already establish: a dedicated native type per provider, not the shared unified one (confirmed both other providers already follow this; Vercel was the outlier). Narrowing this type surfaced exactly the one call site that needed fixing — nothing else broke.

mapUnifiedActionToVercel maps allowbypass (skip further mitigation — Vercel's closest equivalent to letting a request through) and blockdeny (Vercel's actual block-like action); the other 6 unified action types are already valid Vercel actions and pass through unchanged. Every unified ActionType has a real Vercel action to land on, so — unlike #261's operator fix — this never needs to warn or drop a condition.

Test plan

  • Regression tests for allowbypass, blockdeny, and all 6 already-native actions passing through unchanged
  • Two mutation-verification passes (reverting to the raw passthrough, and separately corrupting just the allow/block mapping values while keeping the function wired up) — each confirmed the right tests fail with a clear message, restored
  • pnpm compile && pnpm test && pnpm lint all pass (1781 tests, 0 lint errors)

…ng through

unifiedToVercel used `rule.action.type` directly with no mapping at all,
so a rule with action: {type: 'allow'} or {type: 'block'} passed
doorman's own local validation (against the wider 8-value unified
ActionType) and was dispatched to Vercel's real API carrying a
mitigate.action value Vercel's own native schema (log, deny, challenge,
bypass, rate_limit, redirect -- 6 values, no allow/block) says is
invalid.

Added VercelActionType (types/vercel.ts), Vercel's actual native action
vocabulary -- previously VercelMitigationAction.action reused the wider
unified ActionType directly, so TypeScript never caught the mismatch
either. This matches the pattern CloudflareAction/FastlyRequestActionType
already establish: a dedicated native type per provider, not the shared
unified one. Narrowing this type surfaced exactly the one call site that
needed fixing.

mapUnifiedActionToVercel maps allow -> bypass (skip further mitigation,
Vercel's closest equivalent to letting a request through) and block ->
deny (Vercel's actual block-like action); the other 6 unified action
types are already valid Vercel actions and pass through unchanged.
Every unified ActionType has a real Vercel action to land on, so this
never needs to warn or drop a condition, unlike #261's operator fix.
@gfargo
gfargo merged commit 982dc4c into main Aug 25, 2026
2 checks passed
@gfargo
gfargo deleted the fix/vercel-allow-block-action-mapping branch August 25, 2026 13:17
github-actions Bot pushed a commit that referenced this pull request Aug 25, 2026
## [3.15.4](v3.15.3...v3.15.4) (2026-08-25)

### Bug Fixes

* map unified allow/block to valid Vercel actions instead of passing through ([#280](#280)) ([982dc4c](982dc4c)), closes [#261](#261)
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 3.15.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

gfargo added a commit that referenced this pull request Aug 25, 2026
…) are fixed (#282)

ne/not_contains/not_in and allow/block were documented as known-bugs to
avoid on Vercel; both are now correctly handled (neg-flag composition
and bypass/deny remapping respectively, per #279/#280). gt/ge/lt/le
remain a genuine platform gap -- Vercel has no numeric-comparison
operator at all -- but that's now a documented, safe drop-with-warning
rather than a silent bug to avoid.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vercel translator passes through allow/block action types invalid in Vercel's native schema

1 participant