{"record":{"id":"6dfcfd35dd399b5a","repo":"a-b-street/abstreet","slug":"url-url-doesn-t-seem-to-have-query-params","errorCode":null,"errorMessage":"URL {url} doesn't seem to have query params","messagePattern":"URL (.+?) doesn't seem to have query params","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"abstutil/src/cli.rs","lineNumber":57,"sourceCode":"    if result.is_empty() {\n        result\n    } else {\n        format!(\"?{}\", result)\n    }\n}\n\n#[cfg(target_arch = \"wasm32\")]\nfn parse_args() -> anyhow::Result<Vec<String>> {\n    let window = web_sys::window().ok_or(anyhow!(\"no window?\"))?;\n    let url = window.location().href().map_err(|err| {\n        anyhow!(err\n            .as_string()\n            .unwrap_or(\"window.location.href failed\".to_string()))\n    })?;\n    // Consider using a proper url parsing crate. This works fine for now, though.\n    let url_parts = url.split(\"?\").collect::<Vec<_>>();\n    if url_parts.len() != 2 {\n        bail!(\"URL {url} doesn't seem to have query params\");\n    }\n    let parts = url_parts[1]\n        .split(\"&\")\n        .map(|x| x.replace(\"%20\", \" \").to_string())\n        .collect::<Vec<_>>();\n    Ok(parts)\n}\n","sourceCodeStart":39,"sourceCodeEnd":65,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/abstutil/src/cli.rs#L39-L65","documentation":"abstutil::parse_args on web reads arguments from the page URL's query string. It splits window.location.href on \"?\" and requires exactly one \"?\"; if there is no query string (or multiple \"?\"s), it bails with \"URL ... doesn't seem to have query params\". It is how web builds emulate CLI args.","triggerScenarios":"Loading the web app at a URL without any \"?...\" query string; URLs containing a \"?\" inside a fragment or more than one \"?\"; calling cli_args before the location is set.","commonSituations":"Opening the deployed app directly without appending parameters; broken links generated without the query portion; redirects stripping the query string.","solutions":["Append the expected query parameters to the URL, e.g. https://host/path?map=/data/system/atwater.parcel_map.","If arguments are optional, catch this error and fall back to defaults instead of failing.","Sanitize generated URLs so they always include the query string, and avoid raw \"?\" in parameter values (use %3F)."],"exampleFix":"// before\nlet args = abstutil::cli_args();\n// after\nlet args = abstutil::cli_args().unwrap_or_else(|_| vec![\"--default\".to_string()]);","handlingStrategy":"try-catch","validationCode":"let has_query = web_sys::window()\n    .and_then(|w| w.location().href().ok())\n    .map(|href| href.contains('?'))\n    .unwrap_or(false);","typeGuard":null,"tryCatchPattern":"let args = abstutil::cli_args().unwrap_or_else(|_| {\n    log::info!(\"no query params; using defaults\");\n    Vec::new()\n});","preventionTips":["Always launch web builds with the required query string in the URL.","Treat CLI args as optional on web and provide defaults.","Percent-encode '?' and other special characters inside parameter values."],"tags":["web","cli","url","arguments"],"backgroundTag":"invalid-url-format","analyzedSha":"0964f29315820c91b171b585eb51e300164e9197","analyzedAt":"2026-09-13T18:02:03.421Z","contentChangedAt":"2026-09-13T18:02:03.421Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}