{"record":{"id":"096286b888088bd5","repo":"OpenBB-finance/OpenBB","slug":"table-id-cannot-be-none","errorCode":null,"errorMessage":"table_id cannot be None","messagePattern":"table_id cannot be None","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"openbb_platform/providers/imf/openbb_imf/utils/metadata.py","lineNumber":1497,"sourceCode":"                base_hierarchy_id = table_id\n        else:\n            selected_table = available_hierarchies[0]\n            table_id = selected_table.get(\"id\", \"\")\n            if table_id and \":\" in table_id:\n                base_hierarchy_id, top_level_code_filter = table_id.split(\":\", 1)\n            else:\n                base_hierarchy_id = table_id\n\n        # Handle hierarchy-based presentations\n        # Use base_hierarchy_id to look up the actual hierarchy object\n        hierarchy = self.hierarchies.get(base_hierarchy_id or table_id)\n        if not hierarchy:\n            raise ValueError(\n                f\"Hierarchy '{base_hierarchy_id or table_id}' not found in cache\"\n            )\n\n        if not table_id:\n            raise ValueError(\"table_id cannot be None\")\n\n        codelist_id = self._hierarchy_to_codelist_map.get(base_hierarchy_id or table_id)\n\n        dataflow_obj = self.dataflows.get(dataflow_id, {})\n        agency_id = dataflow_obj.get(\"agencyID\", \"IMF\")\n        agency_clean = agency_id.replace(\".\", \"_\")\n\n        structure_ref = dataflow_obj.get(\"structureRef\", {})\n        dsd_id = structure_ref.get(\"id\")\n        dsd_obj = self.datastructures.get(dsd_id, {}) if dsd_id else {}\n        dimensions = dsd_obj.get(\"dimensions\", []) if isinstance(dsd_obj, dict) else []\n\n        indicator_dimension_order: dict[str, int] = {}\n        indicator_id_candidates = [\n            \"INDICATOR\",\n            \"PRODUCTION_INDEX\",\n            \"COICOP_1999\",\n            \"ACTIVITY\",","sourceCodeStart":1479,"sourceCodeEnd":1515,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/imf/openbb_imf/utils/metadata.py#L1479-L1515","documentation":"Defensive guard in get_dataflow_hierarchy_table: after hierarchy resolution, table_id is still falsy. In practice this only happens when no table_id was passed and the first available hierarchy entry has an empty/missing 'id' — the earlier 'if not table_id' branches never assigned a real value. It marks corrupt hierarchy entries rather than a user mistake.","triggerScenarios":"table_id=None plus available_hierarchies[0] lacking an 'id' key or having id=''; a malformed hierarchy.json entry with no id.","commonSituations":"Hand-edited or truncated hierarchy cache files; upstream JSON schema change dropping the id field.","solutions":["Pass an explicit, known-good table_id (from get_dataflow_hierarchies) instead of relying on the first entry.","Inspect available_hierarchies[0] for a missing 'id' and refresh the metadata caches.","Filter entries without ids when building your own table picker."],"exampleFix":"# before\ntable = meta.get_dataflow_hierarchy_table(df_id, None)\n\n# after\nids = [h['id'] for h in meta.get_dataflow_hierarchies(df_id) if h.get('id')]\ntable = meta.get_dataflow_hierarchy_table(df_id, ids[0] if ids else None)","handlingStrategy":"validation","validationCode":"ids = [h['id'] for h in meta.get_dataflow_hierarchies(df_id) if h.get('id')]\nsafe_table_id = ids[0] if ids else None\nif safe_table_id is None:\n    raise ValueError('No well-formed hierarchy entries for this dataflow')","typeGuard":null,"tryCatchPattern":"try:\n    meta.get_dataflow_hierarchy_table(df_id, None)\nexcept ValueError as e:\n    if 'table_id cannot be None' in str(e):\n        pass  # corrupt first entry: handled by pre-filtering ids\n    else:\n        raise","preventionTips":["Filter hierarchy entries lacking 'id' before presenting choices.","Pass explicit table ids instead of relying on first-entry defaults."],"tags":["imf","sdmx","hierarchy","defensive","corrupt-data"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}