{"record":{"id":"490bf1b1d3534a92","repo":"hoppscotch/hoppscotch","slug":"query-param-key-must-be-a-string","errorCode":null,"errorMessage":"Query param key must be a string","messagePattern":"Query param key must be a string","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/hoppscotch-js-sandbox/src/bootstrap-code/pre-request.js","lineNumber":603,"sourceCode":"          get: () => {\n            return {\n              // Basic manipulation methods\n              add: (param) => {\n                if (!param || !param.key)\n                  throw new Error(\"Query param must have a 'key' property\")\n                const currentParsed = urlObj._parseUrl()\n                currentParsed.queryParams.push({\n                  key: param.key,\n                  value: param.value || \"\",\n                })\n                globalThis.hopp.request.setUrl(\n                  urlObj._rebuildUrl(currentParsed)\n                )\n              },\n\n              remove: (key) => {\n                if (typeof key !== \"string\")\n                  throw new Error(\"Query param key must be a string\")\n                const currentParsed = urlObj._parseUrl()\n                currentParsed.queryParams = currentParsed.queryParams.filter(\n                  (p) => p.key !== key\n                )\n                globalThis.hopp.request.setUrl(\n                  urlObj._rebuildUrl(currentParsed)\n                )\n              },\n\n              upsert: (param) => {\n                if (!param || !param.key)\n                  throw new Error(\"Query param must have a 'key' property\")\n                const currentParsed = urlObj._parseUrl()\n                const idx = currentParsed.queryParams.findIndex(\n                  (p) => p.key === param.key\n                )\n                if (idx >= 0) {\n                  currentParsed.queryParams[idx].value = param.value || \"\"","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/hoppscotch/hoppscotch/blob/1acb8a3a7581e4db32ba0d529170c4669a2e1053/packages/hoppscotch-js-sandbox/src/bootstrap-code/pre-request.js#L585-L621","documentation":"Thrown by pm.request.url.query.remove() when the key argument is not a string. The method compares each existing param's key against the supplied key, so a non-string would never match and would hide a no-op bug; the guard makes the misuse explicit.","triggerScenarios":"Calling query.remove(123), query.remove({key:'a'}), query.remove(['a']), query.remove(undefined), or query.remove(null). Passing a param object instead of its key string is the most common form.","commonSituations":"Passing the whole param object from a each() callback instead of p.key; passing a numeric key; passing an array of keys (remove only takes one — use removeQueryParams for bulk).","solutions":["Pass the key as a string: query.remove('a').","If you have an object, pass its key field: query.remove(obj.key).","For multiple keys, use pm.request.url.removeQueryParams(['a','b'])."],"exampleFix":"// before\npm.request.url.query.remove(foundParam)\n\n// after\npm.request.url.query.remove(foundParam.key)","handlingStrategy":"type-guard","validationCode":"if (typeof key !== 'string') {\n  throw new Error('query.remove requires a string key');\n}","typeGuard":"function isStringKey(v) {\n  return typeof v === 'string' && v.length > 0;\n}","tryCatchPattern":"try {\n  pm.request.url.query.remove(key);\n} catch (e) {\n  if (/must be a string/.test(e.message) && key && key.key) pm.request.url.query.remove(key.key);\n  else throw e;\n}","preventionTips":["Pass the key string, not the param object.","Use removeQueryParams for bulk removal of multiple keys.","Treat numeric-looking keys as strings from the start."],"tags":["query-params","validation","type-check","pre-request"],"backgroundTag":null,"analyzedSha":"1acb8a3a7581e4db32ba0d529170c4669a2e1053","analyzedAt":"2026-08-12T11:34:52.648Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}