{"record":{"id":"2bcb6eb436f7269f","repo":"anomalyco/sst","slug":"invalid-route-type","errorCode":null,"errorMessage":"Invalid route type","messagePattern":"Invalid route type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/router.ts","lineNumber":2027,"sourceCode":"                                path,\n                                route.edge.viewerResponse,\n                              ).arn,\n                            },\n                          ]\n                        : []),\n                    ],\n                    viewerProtocolPolicy: \"redirect-to-https\",\n                    allowedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n                    cachedMethods: [\"GET\", \"HEAD\"],\n                    compress: true,\n                    // CloudFront's managed CachingOptimized policy\n                    cachePolicyId:\n                      route.cachePolicy ??\n                      \"658327ea-f89d-4fab-a63d-7e88639e58f6\",\n                  },\n                };\n              }\n              throw new Error(\"Invalid route type\");\n            },\n          );\n\n          return new Cdn(\n            ...transform(\n              args.transform?.cdn,\n              `${name}Cdn`,\n              {\n                comment: `${name} router`,\n                origins: distributionData.map((d) => d.origin),\n                defaultCacheBehavior: {\n                  ...distributionData.find(\n                    (d) => d.behavior.pathPattern === \"/*\",\n                  )!.behavior,\n                  // @ts-expect-error\n                  pathPattern: undefined,\n                },\n                orderedCacheBehaviors: distributionData","sourceCodeStart":2009,"sourceCodeEnd":2045,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/router.ts#L2009-L2045","documentation":"Inside createCdn, route entries are normalized into CloudFront origin definitions per route type. After normalization any route not matching a known type (url or bucket) reaches the terminal `throw new Error(\"Invalid route type\")`, indicating the internal route union was exhausted without a match.","triggerScenarios":"A route object in `args.routes` whose normalized shape matches neither the url-route nor bucket-route variant when building the CDN origins — typically from a non-standard route object shape passed through the routes map.","commonSituations":"Manually crafted route objects with malformed/unexpected fields; internal drift between route normalization and CDN creation when upgrading SST; casting arbitrary objects as routes.","solutions":["Ensure each route is either a plain URL string or an object with only `url` (+ optional url args) or `bucket` (+ optional bucket args)","Log/inspect the routes config you pass to Router to find the malformed entry","Upgrade SST — if it occurs with seemingly valid config, it may be a version bug; check the Router docs for the current route shape"],"exampleFix":"// before\nroutes: { \"/*\": { href: \"https://example.com\" } } // unknown key\n// after\nroutes: { \"/*\": { url: \"https://example.com\" } }","handlingStrategy":"type-guard","validationCode":"const known = (r: any) =>\n  typeof r === \"string\" ||\n  (r && (\"url\" in r || \"bucket\" in r)) &&\n  Object.keys(r).every((k) => [\"url\", \"bucket\"].includes(k));\nObject.values(routes).forEach((r) => { if (!known(r)) throw new Error(\"Unknown route shape: \" + JSON.stringify(r)); });","typeGuard":"function isKnownRoute(r: unknown): r is string | { url: unknown } | { bucket: unknown } {\n  return typeof r === \"string\" ||\n    (typeof r === \"object\" && r !== null && (\"url\" in r || \"bucket\" in r));\n}","tryCatchPattern":"try {\n  const r = new Router(ctx, \"R\", { routes });\n} catch (e) {\n  if (String(e) === \"Invalid route type\") console.error(\"Malformed route entry passed to Router\");\n  throw e;\n}","preventionTips":["Only pass route shapes from the documented Router API (string, {url}, {bucket})","Never cast arbitrary JSON as route args","After SST upgrades, rebuild route configs against the current docs"],"tags":["router","route-validation","cloudfront","sst"],"backgroundTag":"invalid-route-path","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}