{"record":{"id":"9468a839c5ee02c9","repo":"vercel/next.js","slug":"invalid-source-matcher-regexp","errorCode":null,"errorMessage":"Invalid source: ${matcher.regexp}","messagePattern":"Invalid source: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/shared/lib/turbopack/manifest-loader.ts","lineNumber":819,"sourceCode":"\n    if (this.dev && !this.middlewareManifests.takeChanged()) {\n      return {\n        clientMiddlewareManifestPath,\n      }\n    }\n    const middlewareManifest = this.mergeMiddlewareManifests(\n      this.middlewareManifests.values()\n    )\n\n    // Server middleware manifest\n\n    // Normalize regexes as it uses path-to-regexp\n    for (const key in middlewareManifest.middleware) {\n      middlewareManifest.middleware[key].matchers.forEach((matcher) => {\n        if (!matcher.regexp.startsWith('^')) {\n          const parsedPage = tryToParsePath(matcher.regexp)\n          if (parsedPage.error || !parsedPage.regexStr) {\n            throw new Error(`Invalid source: ${matcher.regexp}`)\n          }\n          matcher.regexp = parsedPage.regexStr\n        }\n      })\n    }\n\n    const middlewareManifestPath = join(\n      this.distDir,\n      'server',\n      MIDDLEWARE_MANIFEST\n    )\n    this.pendingCacheDeletes.push(middlewareManifestPath)\n    writeFileAtomic(\n      middlewareManifestPath,\n      JSON.stringify(middlewareManifest, null, 2)\n    )\n\n    // Client middleware manifest This is only used in dev though, packages/next/src/build/index.ts","sourceCodeStart":801,"sourceCodeEnd":837,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/shared/lib/turbopack/manifest-loader.ts#L801-L837","documentation":"While merging server middleware manifests, TurbopackManifestLoader normalizes matcher regexes that don't start with '^' via tryToParsePath (path-to-regexp); this error is thrown when parsing still fails, meaning a middleware matcher from the Turbopack manifest cannot be converted into a valid anchored RegExp.","triggerScenarios":"A redirect/rewrite source fails manifest validation.","commonSituations":"An invalid matcher regexp in a route manifest entry loaded by Turbopack.","solutions":["Fix the source pattern in the route/rewrite config so it compiles to a valid matcher."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}