{"record":{"id":"d34d0d0e4985e07d","repo":"facebookresearch/detectron2","slug":"unsupported-query-remaining-f-queries-orginal-f","errorCode":null,"errorMessage":"Unsupported query remaining: f{queries}, orginal filename: {parsed_url.geturl()}","messagePattern":"Unsupported query remaining: f(.+?), orginal filename: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"detectron2/checkpoint/detection_checkpoint.py","lineNumber":108,"sourceCode":"                \"model_state\" in data\n            ), f\"Cannot load .pyth file {filename}; pycls checkpoints must contain 'model_state'.\"\n            model_state = {\n                k: v\n                for k, v in data[\"model_state\"].items()\n                if not k.endswith(\"num_batches_tracked\")\n            }\n            return {\"model\": model_state, \"__author__\": \"pycls\", \"matching_heuristics\": True}\n\n        loaded = self._torch_load(filename)\n        if \"model\" not in loaded:\n            loaded = {\"model\": loaded}\n        assert self._parsed_url_during_load is not None, \"`_load_file` must be called inside `load`\"\n        parsed_url = self._parsed_url_during_load\n        queries = parse_qs(parsed_url.query)\n        if queries.pop(\"matching_heuristics\", \"False\") == [\"True\"]:\n            loaded[\"matching_heuristics\"] = True\n        if len(queries) > 0:\n            raise ValueError(\n                f\"Unsupported query remaining: f{queries}, orginal filename: {parsed_url.geturl()}\"\n            )\n        return loaded\n\n    def _torch_load(self, f):\n        return super()._load_file(f)\n\n    def _load_model(self, checkpoint):\n        if checkpoint.get(\"matching_heuristics\", False):\n            self._convert_ndarray_to_tensor(checkpoint[\"model\"])\n            # convert weights by name-matching heuristics\n            checkpoint[\"model\"] = align_and_update_state_dicts(\n                self.model.state_dict(),\n                checkpoint[\"model\"],\n                c2_conversion=checkpoint.get(\"__author__\", None) == \"Caffe2\",\n            )\n        # for non-caffe2 models, use standard ways to load it\n        incompatible = super()._load_model(checkpoint)","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/facebookresearch/detectron2/blob/a2f4a8771ab77e8411c26b27f24f9489a28a2453/detectron2/checkpoint/detection_checkpoint.py#L90-L126","documentation":"DetectionCheckpointer._load_file supports only the 'matching_heuristics=True' URL query parameter. After popping it, any remaining query string in the checkpoint path causes this ValueError because the loader cannot interpret other options.","triggerScenarios":"Loading a checkpoint with a URL like 'model.pth?matching_heuristics=True&strict=False' or any path containing '?' followed by unrecognized key=value pairs.","commonSituations":"Trying to pass torch.load options (e.g. map_location, strict) through the checkpoint filename; copying example URLs with extra parameters; hand-crafting query strings assuming generic support.","solutions":["Remove unsupported query parameters from the path and configure those options in code instead","Pass only ?matching_heuristics=True if you need suffix matching","For options like device mapping, subclass DetectionCheckpointer and override _load_file/_torch_load"],"exampleFix":"# before\nckpt.load(\"model.pth?matching_heuristics=True&strict=False\")\n# after\nckpt.load(\"model.pth?matching_heuristics=True\")  # strictness handled via model.load_state_dict yourself","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse, parse_qs\nq = parse_qs(urlparse(path).query)\nassert set(q) <= {\"matching_heuristics\"}, f\"unsupported queries: {set(q) - {'matching_heuristics'}}\"","typeGuard":"def is_supported_ckpt_path(path: str) -> bool:\n    return set(parse_qs(urlparse(path).query)) <= {\"matching_heuristics\"}","tryCatchPattern":"try:\n    ckpt.load(path)\nexcept ValueError as e:\n    if \"Unsupported query\" in str(e):\n        ckpt.load(urlparse(path).path + \"?matching_heuristics=True\")\n    else:\n        raise","preventionTips":["Only use the documented matching_heuristics query parameter","Pass load options via checkpointer subclassing, not URLs","Add a path sanitizer before calling load"],"tags":["checkpoint","url-query","invalid-argument"],"backgroundTag":"unsupported-query-parameter","analyzedSha":"a2f4a8771ab77e8411c26b27f24f9489a28a2453","analyzedAt":"2026-08-27T12:08:21.260Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}