{"record":{"id":"413f0ace5a8400a4","repo":"OpenBB-finance/OpenBB","slug":"data-structure-not-found-for-dataflow-dataflow-i","errorCode":null,"errorMessage":"Data structure not found for dataflow '{dataflow_id}'.","messagePattern":"Data structure not found for dataflow '(.+?)'\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/imf/openbb_imf/utils/metadata.py","lineNumber":809,"sourceCode":"        with self._constraints_lock:\n            self._constraints_cache[cache_key] = result\n\n        return result\n\n    def get_indicators_in(self, dataflow_id: str) -> list:\n        \"\"\"Get indicators available in a given dataflow.\"\"\"\n        if dataflow_id not in self.dataflows:\n            raise ValueError(f\"Dataflow '{dataflow_id}' not found.\")\n\n        dataflow_obj = self.dataflows[dataflow_id]\n        dataflow_name = dataflow_obj.get(\"name\", \"\").replace(\"\\\\xa0\", \"\").strip()\n        structure_ref = dataflow_obj.get(\"structureRef\", {})\n        structure_id = structure_ref.get(\"id\", \"\")\n        agency_id = dataflow_obj.get(\"agencyID\", structure_ref.get(\"agencyID\", \"IMF\"))\n        dsd_id = structure_ref.get(\"id\", \"\")\n\n        if not dsd_id or dsd_id not in self.datastructures:\n            raise ValueError(f\"Data structure not found for dataflow '{dataflow_id}'.\")\n\n        dsd = self.datastructures[dsd_id]\n        all_dims = dsd.get(\"dimensions\", [])\n\n        # Get valid codes from parameters API\n        try:\n            params = self.get_dataflow_parameters(dataflow_id)\n        except Exception:  # noqa: BLE001\n            params = {}\n\n        full_indicator_list = []\n\n        indicator_id_candidates = [\n            \"INDICATOR\",\n            \"PRODUCTION_INDEX\",\n            \"COICOP_1999\",\n            \"INDEX_TYPE\",\n            \"ACTIVITY\",","sourceCodeStart":791,"sourceCodeEnd":827,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/imf/openbb_imf/utils/metadata.py#L791-L827","documentation":"Raised by get_indicators_in when the dataflow exists but its structureRef.id is empty or the referenced Data Structure Definition (DSD) is absent from self.datastructures. This means the catalog loaded the dataflow entry but not the structure needed to enumerate indicator dimensions, so indicator discovery cannot proceed.","triggerScenarios":"A dataflow whose JSON entry lacks 'structureRef.id'; a DSD id that is not present in the loaded datastructures cache (partial structure.json); agency-specific structures referenced but never fetched.","commonSituations":"Truncated or stale cached structure.json, new/renamed DSDs on the IMF side not yet in the local cache, dataflows maintained by agencies other than IMF whose structures use a different key.","solutions":["Refresh/re-download the structure metadata so self.datastructures includes the DSD referenced by the dataflow.","Inspect meta.dataflows[dataflow_id]['structureRef'] to see which DSD id is being requested and whether it is empty.","If structureRef.id is genuinely empty upstream, skip this dataflow and report it rather than retrying."],"exampleFix":"# before\ninds = meta.get_indicators_in(dataflow_id)\n\n# after\ndsd_id = meta.dataflows.get(dataflow_id, {}).get('structureRef', {}).get('id', '')\nif not dsd_id or dsd_id not in meta.datastructures:\n    # re-fetch structures or pick another dataflow\n    ...\ninds = meta.get_indicators_in(dataflow_id)","handlingStrategy":"validation","validationCode":"ref = meta.dataflows.get(dataflow_id, {}).get('structureRef', {})\ndsd_id = ref.get('id', '')\nhas_structure = bool(dsd_id) and dsd_id in meta.datastructures\nif not has_structure:\n    print(f'DSD {dsd_id!r} missing for {dataflow_id}; refresh structures')","typeGuard":"def dataflow_has_structure(meta, df_id: str) -> bool:\n    ref = meta.dataflows.get(df_id, {}).get('structureRef', {})\n    return bool(ref.get('id')) and ref['id'] in meta.datastructures","tryCatchPattern":"try:\n    meta.get_indicators_in(df_id)\nexcept ValueError as e:\n    if 'Data structure not found' in str(e):\n        # cache/consistency issue: refreshing metadata is the remedy, not retry-as-is\n        meta = reload_metadata()\n    else:\n        raise","preventionTips":["Treat dataflow.json and structure.json as an atomic pair when caching; refresh both together.","Skip dataflows lacking structureRef.id during catalog crawls instead of letting them raise."],"tags":["imf","sdmx","metadata","datastructure","validation"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}