{"record":{"id":"fa63885ab567983a","repo":"OpenBB-finance/OpenBB","slug":"agency-id-not-found-for-dataflow-dataflow","errorCode":null,"errorMessage":"Agency ID not found for dataflow '{dataflow}'.","messagePattern":"Agency ID not found for dataflow '(.+?)'\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/imf/openbb_imf/utils/query_builder.py","lineNumber":87,"sourceCode":"            param_value = final_kwargs.get(dim_id)\n\n            # Handle wildcards and empty values\n            if (\n                param_value is None\n                or param_value in [\"\", \"*\"]\n                or len(str(param_value)) > 1500\n            ):\n                key_parts.append(\"*\")\n            elif isinstance(param_value, list):\n                key_parts.append(\"+\".join(param_value))\n            else:\n                key_parts.append(str(param_value))\n            dimensions_in_key.add(dim_id)\n\n        key = \".\".join(key_parts)\n\n        if not agency_id:\n            raise ValueError(f\"Agency ID not found for dataflow '{dataflow}'.\")\n\n        url = (\n            f\"https://api.imf.org/external/sdmx/3.0/data/dataflow/\"\n            f\"{agency_id}/{dataflow}/+/{key}\"\n        )\n        # Only include parameters in query_params that are not dimensions\n        query_params = {\n            k: v for k, v in final_kwargs.items() if k not in dimensions_in_key\n        }\n        # Format dates for TIME_PERIOD filter\n        frequency = (final_kwargs.get(\"FREQUENCY\") or \"\").upper()\n\n        def format_date(\n            date_str: str, frequency: str, is_end_date: bool = False\n        ) -> str:\n            \"\"\"Format date string based on frequency to match IMF TIME_PERIOD format.\"\"\"\n            if not date_str:\n                return date_str","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/imf/openbb_imf/utils/query_builder.py#L69-L105","documentation":"build_url raises ValueError at URL-assembly time when the dataflow metadata contains no agencyID. The SDMX 3.0 data endpoint requires agency/dataflow in the path, so without it no valid URL can be produced.","triggerScenarios":"A dataflow entry in metadata lacking the agencyID field (malformed/partial cache) or an unexpected IMF registry change altering the metadata shape.","commonSituations":"Stale or hand-modified metadata cache, partial metadata fetch, or provider version that parses an older SDMX structure format.","solutions":["Clear the cached IMF metadata and re-fetch.","Upgrade openbb-imf if IMF changed the metadata schema.","Use another dataflow for the same data while the broken one is fixed upstream."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"def dataflow_has_agency(qb, dataflow: str) -> bool:\n    return bool(qb.metadata.dataflows.get(dataflow, {}).get('agencyID'))","typeGuard":null,"tryCatchPattern":"try:\n    url = qb.build_url(dataflow, **kwargs)\nexcept ValueError as e:\n    if 'Agency ID not found' in str(e):\n        refresh_imf_metadata_cache()\n        url = qb.build_url(dataflow, **kwargs)\n    else:\n        raise","preventionTips":["Validate metadata completeness (agencyID, structureRef) after any cache write.","Do not hand-edit cached IMF metadata.","Report dataflows with missing agencyID upstream — it is a metadata defect."],"tags":["metadata","imf","sdmx","cache","upstream"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}