{"record":{"id":"8f12bce1643faeba","repo":"OpenBB-finance/OpenBB","slug":"invalid-value-s-for-dimension-dim-id-invali-8f12bc","errorCode":null,"errorMessage":"Invalid value(s) for dimension '{dim_id}': {invalid_values}. Given prior selections {prior_selections}, available values are: {display_values}","messagePattern":"Invalid value\\(s\\) for dimension '(.+?)': (.+?)\\. Given prior selections (.+?), available values are: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/imf/openbb_imf/utils/table_builder.py","lineNumber":542,"sourceCode":"                            if isinstance(user_value, str) and \"+\" in user_value\n                            else [user_value]\n                        )\n                        invalid_values = [\n                            v\n                            for v in user_values\n                            if v not in available_values and v != \"*\"\n                        ]\n\n                        if invalid_values:\n                            # Build prior selections for context\n                            prior_selections = {\n                                d: normalized_kwargs.get(d)\n                                for d in dims_in_order\n                                if d in normalized_kwargs\n                                and dims_in_order.index(d) < dims_in_order.index(dim_id)\n                            }\n                            display_values = sorted(available_values)\n                            raise ValueError(\n                                f\"Invalid value(s) for dimension '{dim_id}': {invalid_values}. \"\n                                f\"Given prior selections {prior_selections}, \"\n                                f\"available values are: {display_values}\"\n                            )\n\n                    builder.set_dimension((dim_id, user_value))\n                    fetch_kwargs[dim_id] = user_value\n                # If this dimension has hierarchy codes, filter them against available\n                elif dim_id in dimension_codes:\n                    # Check if user explicitly provided this dimension (e.g., INDICATOR='*')\n                    # If so, use their value for the builder but still process hierarchy codes\n                    user_override = normalized_kwargs.get(dim_id)\n                    codes = dimension_codes[dim_id]\n                    available_options = builder.get_options_for_dimension(dim_id)\n                    available_values = {opt[\"value\"] for opt in available_options}\n                    filtered_codes = [c for c in codes if c in available_values]\n                    # If no exact matches, try prefix matching for INDICATOR dimension\n                    # Hierarchies may use base codes (FSI688_TREGK) while dataflow has","sourceCodeStart":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/imf/openbb_imf/utils/table_builder.py#L524-L560","documentation":"Progressive-dimension validation error from the IMF table builder: a user-supplied value for a dimension (e.g. COUNTRY='XX') is not in the set of values the SDMX builder reports as available, given the dimensions already selected before it in the dimension order. It exists to fail fast with context instead of returning an empty or confusing API response.","triggerScenarios":"Passing a dimension value that is invalid for the table given earlier selections - e.g. fetch(..., COUNTRY='EURO') where that code isn't in the codelist, or an INDICATOR code that doesn't exist once COUNTERPART_AREA or frequency was fixed. Raised while iterating dims_in_order and normalizing kwargs against builder.get_options_for_dimension().","commonSituations":"Typos or outdated ISO/country codes; using indicator codes from one IMF dataset in another; case mismatches ('us' vs 'US'); combining dimension filters that are mutually exclusive for the chosen table.","solutions":["Read the message: it lists the exact available values for the failing dimension - pick one of those instead of your current value.","Check earlier selections reported as prior_selections; relax or correct one of them, since availability is conditional on those.","Normalize codes (uppercase, ISO-3 country codes, official SDMX indicator IDs) before passing them.","If the value should be valid, refresh provider metadata/caches - IMF codelists may have changed."],"exampleFix":"# before\nobb.economy.imf.fetch(dataset='IFS', parameters={'COUNTRY': 'USS', 'INDICATOR': 'EDP'})\n# after - use a country code from the reported available values\nobb.economy.imf.fetch(dataset='IFS', parameters={'COUNTRY': 'USA', 'INDICATOR': 'EDP'})","handlingStrategy":"validation","validationCode":"# Validate dimension values against the table's own options before fetching\nparams = {'COUNTRY': 'USA', 'INDICATOR': 'EDP'}\noptions = obb.economy.imf.dimension_options(dataset='IFS', dimension='COUNTRY')  # or equivalent\nvalid = {o.value for o in options.results}\nbad = {k: v for k, v in params.items() if k == 'COUNTRY' and v not in valid}\nassert not bad, f'Invalid dimension values: {bad}; choose from {sorted(valid)[:10]}...'","typeGuard":"def is_valid_dimension_value(value: str, available: set[str]) -> bool:\n    \"\"\"True when value is an available code or the wildcard.\"\"\"\n    return value == '*' or value in available","tryCatchPattern":"try:\n    res = obb.economy.imf.fetch(dataset='IFS', parameters=params)\nexcept ValueError as e:\n    if 'Invalid value(s) for dimension' in str(e):\n        # message lists valid values - parse and re-prompt user / pick first valid\n        handle_invalid_dimension(str(e))\n    raise","preventionTips":["Uppercase and normalize codes before passing","Never mix indicator codes across datasets","Build parameter dicts from discovered codelist options, not hardcoded strings"],"tags":["imf","validation","dimension-filter","valueerror"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}