{"record":{"id":"2f85f0289d2fbecd","repo":"vercel/next.js","slug":"genericfailure","errorCode":"GenericFailure","errorMessage":"invalid type for RouteHas: {type_}","messagePattern":"invalid type for RouteHas: (.+?)","errorType":"exception","errorClass":"napi::Error","httpStatus":null,"severity":"error","filePath":"crates/next-napi-bindings/src/turbopack.rs","lineNumber":182,"sourceCode":"        let type_ = object.get_named_property::<String>(\"type\")?;\n        Ok(match type_.as_str() {\n            \"header\" => NapiRouteHas::Header {\n                key: object.get_named_property(\"key\")?,\n                value: object.get_named_property(\"value\")?,\n            },\n            \"query\" => NapiRouteHas::Query {\n                key: object.get_named_property(\"key\")?,\n                value: object.get_named_property(\"value\")?,\n            },\n            \"cookie\" => NapiRouteHas::Cookie {\n                key: object.get_named_property(\"key\")?,\n                value: object.get_named_property(\"value\")?,\n            },\n            \"host\" => NapiRouteHas::Host {\n                value: object.get_named_property(\"value\")?,\n            },\n            _ => {\n                return Err(napi::Error::new(\n                    Status::GenericFailure,\n                    format!(\"invalid type for RouteHas: {type_}\"),\n                ));\n            }\n        })\n    }\n}\n\nimpl From<NapiRouteHas> for RouteHas {\n    fn from(val: NapiRouteHas) -> Self {\n        match val {\n            NapiRouteHas::Header { key, value } => RouteHas::Header {\n                key: key.into(),\n                value: value.map(From::from),\n            },\n            NapiRouteHas::Query { key, value } => RouteHas::Query {\n                key: key.into(),\n                value: value.map(From::from),","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/crates/next-napi-bindings/src/turbopack.rs#L164-L200","documentation":"At the JavaScript↔Rust NAPI boundary, Next.js passes route-condition objects (the `has` arrays from rewrites/redirects/headers) to Turbopack. NapiRouteHas::from_napi_value reads the 'type' property and matches it case-sensitively against \"header\", \"query\", \"cookie\", or \"host\". Any other value (e.g. \"Header\", \"param\", \"method\") returns a napi Error with Status::GenericFailure back to JavaScript.","triggerScenarios":"Defining a route `has` condition in next.config.js (rewrites/redirects/headers) with a type value outside the supported set, or with wrong casing. The object crosses into the Turbopack NAPI binding and fails deserialization.","commonSituations":"Typing \"Header\" instead of \"header\"; attempting to use an unsupported condition type like \"param\" or \"method\" that webpack-era configs or tutorials may have suggested; copy-paste from docs that used different casing.","solutions":["Use one of the exact lowercase types: \"header\", \"query\", \"cookie\", or \"host\".","Double-check casing — the match is case-sensitive.","Remove unsupported condition types; route on a supported dimension instead."],"exampleFix":"// before\nasync redirects() {\n  return [{ source: '/a', destination: '/b', has: [{ type: 'Header', key: 'x-foo' }], permanent: false }]\n}\n\n// after\nasync redirects() {\n  return [{ source: '/a', destination: '/b', has: [{ type: 'header', key: 'x-foo' }], permanent: false }]\n}","handlingStrategy":"type-guard","validationCode":"// Validate route `has` condition types before passing to Next.js config.\nconst VALID_TYPES = new Set(['header', 'query', 'cookie', 'host']);\nfunction validateRouteHas(has) {\n  for (const h of has) {\n    if (!VALID_TYPES.has(h.type)) {\n      throw new Error(`invalid route has type \"${h.type}\"; expected one of header|query|cookie|host`);\n    }\n  }\n}\n","typeGuard":"// TypeScript narrowing for route `has` conditions.\ntype RouteHasType = 'header' | 'query' | 'cookie' | 'host';\nfunction isRouteHasType(t: string): t is RouteHasType {\n  return t === 'header' || t === 'query' || t === 'cookie' || t === 'host';\n}","tryCatchPattern":null,"preventionTips":["Always lowercase the `type` field in route `has` conditions.","Restrict the type to the four supported values using a TypeScript union.","Add a unit test over your next.config rewrites/redirects/headers to catch typos."],"tags":["napi","routes","route-has","configuration","next-config"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}