remix-run/remix · error · Error
invalid bypass pattern ${JSON.stringify(pattern)}: empty wil
Error message
invalid bypass pattern ${JSON.stringify(pattern)}: empty wildcards are not allowed What it means
parseBypassSegment throws when a wildcard segment is exactly '{}', i.e. an unnamed wildcard. Wildcards must have a name like {id} for the pattern to be meaningful and for downstream matching. An empty '{}' is treated as a malformed pattern.
Source
Thrown at packages/cop-middleware/src/lib/cop.ts:282
function parseBypassSegment(
pattern: string,
segment: string,
isLastSegment: boolean,
): BypassSegment {
if (segment === '') {
throw new Error(
`invalid bypass pattern ${JSON.stringify(pattern)}: empty path segments are not allowed`,
)
}
if (!segment.startsWith('{') || !segment.endsWith('}')) {
return { type: 'static', value: segment }
}
let wildcardName = segment.slice(1, segment.length - 1)
if (wildcardName === '') {
throw new Error(
`invalid bypass pattern ${JSON.stringify(pattern)}: empty wildcards are not allowed`,
)
}
if (wildcardName === '$') {
throw new Error(
`invalid bypass pattern ${JSON.stringify(pattern)}: "{$}" is not supported in cop-middleware`,
)
}
if (wildcardName.endsWith('...')) {
if (!isLastSegment) {
throw new Error(
`invalid bypass pattern ${JSON.stringify(pattern)}: tail wildcards must be last`,
)
}
if (wildcardName.length === 3) {View on GitHub (pinned to 9696913134)
Solutions
- Give the wildcard a name: '/users/{id}' instead of '/users/{}'
- If any single segment should match, still name it, e.g. '/files/{name}'
Example fix
// before
cop.addInsecureBypassPattern('/users/{}')
// after
cop.addInsecureBypassPattern('/users/{id}') Defensive patterns
Strategy: validation
Validate before calling
const segments = path.split('/')
if (segments.some((s) => s === '{}')) throw new Error('empty wildcard in pattern') Type guard
function isValidWildcardSegment(segment: string): boolean {
return !(segment.startsWith('{') && segment.endsWith('}') && segment.length === 2)
} Prevention
- Fill template placeholders before registering patterns
- Unit-test generated patterns
When it happens
Trigger: addInsecureBypassPattern('/users/{}') or any pattern containing a '{}' segment.
Common situations: Placeholder templates left unfilled; regex-based generation of patterns producing '{}' when the capture name is missing; typos deleting the wildcard name.
Related errors
- invalid bypass pattern ${JSON.stringify(pattern)}: tail wild
- invalid bypass pattern ${JSON.stringify(pattern)}: tail wild
- invalid bypass pattern ${JSON.stringify(pattern)}: path must
- invalid bypass pattern ${JSON.stringify(pattern)}: query str
- invalid bypass pattern ${JSON.stringify(pattern)}: empty pat
AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27).
Data as JSON: /api/errors/7082df23c50577eb.
Report an issue: GitHub.