{"id":"9af288e79d430592","repo":"expressjs/express","slug":"unknown-value-for-query-parser-function-val","errorCode":null,"errorMessage":"unknown value for query parser function: ' + val","messagePattern":"unknown value for query parser function: ' \\+ val","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/utils.js","lineNumber":180,"sourceCode":"exports.compileQueryParser = function compileQueryParser(val) {\n  var fn;\n\n  if (typeof val === 'function') {\n    return val;\n  }\n\n  switch (val) {\n    case true:\n    case 'simple':\n      fn = querystring.parse;\n      break;\n    case false:\n      break;\n    case 'extended':\n      fn = parseExtendedQueryString;\n      break;\n    default:\n      throw new TypeError('unknown value for query parser function: ' + val);\n  }\n\n  return fn;\n}\n\n/**\n * Compile \"proxy trust\" value to function.\n *\n * @param  {Boolean|String|Number|Array|Function} val\n * @return {Function}\n * @api private\n */\n\nexports.compileTrust = function(val) {\n  if (typeof val === 'function') return val;\n\n  if (val === true) {\n    // Support plain true/false","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/expressjs/express/blob/a3714473feb3d2908add734d340e7755fd85e0a3/lib/utils.js#L162-L198","documentation":"compileQueryParser (lib/utils.js:162-184) turns the 'query parser' setting into the function that populates req.query. Valid values are a function, true, false, 'simple' (Node's querystring.parse), or 'extended' (qs-style parsing); anything else hits the default case at line 180 and throws a TypeError when the setting is set.","triggerScenarios":"app.set('query parser', 'qs') — 'qs' was a valid alias historically but in this Express 5 code only 'simple'/'extended' strings are accepted; app.set('query parser', 'true') from an env var; any misspelling like 'extened'.","commonSituations":"Upgrading Express 4 apps that used app.set('query parser', 'qs') — Express 5 replaced that with 'extended' and changed the default to 'simple', so upgrade guides mention this exact setting; env-var-sourced config delivering strings; passing the qs module object instead of a parse function.","solutions":["Use 'simple' or 'extended': app.set('query parser', 'extended').","If migrating from Express 4's 'qs' value, replace it with 'extended' (or pass qs.parse directly as a function for full control).","To disable query parsing entirely, pass false (the boolean, not the string)."],"exampleFix":"// before (Express 4 style)\napp.set('query parser', 'qs');\n// after (Express 5)\napp.set('query parser', 'extended');","handlingStrategy":"validation","validationCode":"const VALID_QP = new Set([true, false, 'simple', 'extended']);\nif (!VALID_QP.has(qpSetting) && typeof qpSetting !== 'function') {\n  throw new TypeError(`invalid 'query parser' setting: ${JSON.stringify(qpSetting)}`);\n}\napp.set('query parser', qpSetting);","typeGuard":"function isValidQueryParserSetting(val) {\n  return val === true || val === false || val === 'simple' || val === 'extended' || typeof val === 'function';\n}","tryCatchPattern":"try {\n  app.set('query parser', config.queryParser);\n} catch (err) {\n  if (/unknown value for query parser/.test(err.message)) {\n    // unsupported value from config — surface as a startup configuration error\n  }\n  throw err;\n}","preventionTips":["Stick to documented values: true, false, 'simple', 'extended', or a custom parser function.","Guard against string-typed env/config values ('false' !== false) — coerce before app.set.","Configure the query parser once during bootstrap so misconfiguration is a boot-time failure."],"tags":["express","configuration","query-parser","migration","express-5"],"analyzedSha":"a3714473feb3d2908add734d340e7755fd85e0a3","analyzedAt":"2026-07-31T18:55:36.968Z","schemaVersion":2}