{"record":{"id":"96dfbcf3b875bb8a","repo":"react-navigation/react-navigation","slug":"encountered-without-preceding-in-path-p","errorCode":null,"errorMessage":"Encountered '(' without preceding ':' in path: ${path}","messagePattern":"Encountered '\\(' without preceding ':' in path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/getPatternParts.tsx","lineNumber":52,"sourceCode":"    if (char === ':') {\n      // The segment must start with a colon if it's a param\n      if (current.segment === ':') {\n        isParam = true;\n      } else if (!isRegex) {\n        throw new Error(\n          `Encountered ':' in the middle of a segment in path: ${path}`\n        );\n      }\n    } else if (char === '(' && !isEscaped && !isInCharClass) {\n      if (isParam) {\n        if (isRegex) {\n          // The '(' is part of the regex if we're already inside one\n          regexInnerParens++;\n        } else {\n          isRegex = true;\n        }\n      } else {\n        throw new Error(\n          `Encountered '(' without preceding ':' in path: ${path}`\n        );\n      }\n    } else if (char === ')' && !isEscaped && !isInCharClass) {\n      if (isParam && isRegex) {\n        if (regexInnerParens) {\n          // The ')' is part of the regex if we're already inside one\n          regexInnerParens--;\n        } else {\n          current.pattern += char;\n          isRegex = false;\n          isParam = false;\n        }\n      } else {\n        throw new Error(\n          `Encountered ')' without preceding '(' in path: ${path}`\n        );\n      }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/react-navigation/react-navigation/blob/ab1319d6bbf05eae8dc25e33cbf4dc56494e0f0c/packages/core/src/getPatternParts.tsx#L34-L70","documentation":"Parentheses in a path pattern are only meaningful as part of a param's regex constraint, e.g. ':id(\\d+)'. A '(' that appears without a preceding ':param' has no valid interpretation, so pattern parsing fails. Thrown while normalizing the linking config's path strings.","triggerScenarios":"A linking-config path containing a bare '(' such as 'page(s)/:id' or 'filter(:type)' — parentheses used as literal text or grouping without an associated param.","commonSituations":"Regex habits from other routers applied to plain path text; trying to make optional segments with parens like 'detail(/:id)' instead of the supported ':id?' syntax; leftover regex fragments from copy-paste.","solutions":["Remove the bare parentheses or escape intent another way: 'pages/:id' instead of 'page(s)/:id'.","For optional segments use the question-mark param syntax: 'detail/:id?' where supported.","If a regex is intended, attach it to a param: ':type([a-z]+)' or ':id(\\d+)'.","Search linking config paths for /\\(/ and fix each occurrence."],"exampleFix":"// before\nconst config = { screens: { List: { path: 'page(s)/:id' } } };\n// after\nconst config = { screens: { List: { path: 'pages/:id' } } };\n// regex variant:\nconst config = { screens: { List: { path: 'list/:filter([a-z]+)' } } };","handlingStrategy":"validation","validationCode":"function validateNoBareParens(p) {\n  let open = 0, inParam = false;\n  for (const ch of p) {\n    if (ch === ':') inParam = true;\n    if (ch === '/') inParam = false;\n    if (ch === '(') { if (!inParam) throw new Error(`'(' without ':' in '${p}'`); open++; }\n    if (ch === ')') open--;\n  }\n  return p;\n}","typeGuard":"function parensOnlyAfterParam(p) {\n  return !/[(]/.test(p.replace(/:[^/(]*\\([^)]*\\)/g, ''));\n}","tryCatchPattern":"try {\n  const parts = getPatternParts(path);\n} catch (err) {\n  if (err.message.includes(\"'(' without preceding ':'\")) {\n    console.error(`Remove or param-wrap '(' in: ${path}`);\n  } else throw err;\n}","preventionTips":["Never use parentheses as literal path text; use them only as ':param(regex)'.","Use ':id?' for optional segments, not '(:id)' or 'detail(/:id)'.","Strip regex artifacts when copying patterns from regex tools.","Test-parse every linking path in CI to surface pattern syntax errors early."],"tags":["navigation","deep-linking","linking-config","pattern-parsing"],"backgroundTag":"invalid-linking-config","analyzedSha":"ab1319d6bbf05eae8dc25e33cbf4dc56494e0f0c","analyzedAt":"2026-08-31T14:46:19.520Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}