{"record":{"id":"6581b60f07b7c73c","repo":"OpenBB-finance/OpenBB","slug":"incorrect-email-or-password","errorCode":null,"errorMessage":"Incorrect email or password","messagePattern":"Incorrect email or password","errorType":"http","errorClass":"HTTPException","httpStatus":401,"severity":"error","filePath":"openbb_platform/core/openbb_core/api/auth/user.py","lineNumber":39,"sourceCode":"        password = Env().API_PASSWORD\n\n        is_correct_username = False\n        is_correct_password = False\n\n        if username is not None and password is not None:\n            current_username_bytes = credentials.username.encode(\"utf8\")\n            correct_username_bytes = username.encode(\"utf8\")\n            is_correct_username = secrets.compare_digest(\n                current_username_bytes, correct_username_bytes\n            )\n            current_password_bytes = credentials.password.encode(\"utf8\")\n            correct_password_bytes = password.encode(\"utf8\")\n            is_correct_password = secrets.compare_digest(\n                current_password_bytes, correct_password_bytes\n            )\n\n        if not (is_correct_username and is_correct_password):\n            raise HTTPException(\n                status_code=status.HTTP_401_UNAUTHORIZED,\n                detail=\"Incorrect email or password\",\n                headers={\"WWW-Authenticate\": \"Basic\"},\n            )\n\n\nasync def get_user_service() -> UserService:\n    \"\"\"Get user service.\"\"\"\n    return UserService()\n\n\nasync def get_user_settings(\n    _: Annotated[None, Depends(authenticate_user)],\n    user_service: Annotated[UserService, Depends(get_user_service)],\n) -> UserSettings:\n    \"\"\"Get user settings.\"\"\"\n    return user_service.read_from_file()\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/core/openbb_core/api/auth/user.py#L21-L57","documentation":"Raised by the CPI query-params validator for the `expenditure` field when a token (spaces to underscores, split on commas) is neither in the lowercase `expenditure_choices` set nor in `expenditure_dict_rev` (keys/uppercase forms). The message embeds the full valid-choices text, so the error itself is the documentation for what is accepted. Fails at model construction, before any IMF request.","triggerScenarios":"Passing `expenditure='food'` when the valid choices are COICOP-style categories (e.g. 'food_and_non_alcoholic_beverages'), or a typo like `expenditure='alltems'`, or a comma list containing one invalid item.","commonSituations":"Guessing COICOP category names instead of copying them from the error message or docs; version drift where upstream renamed expenditure categories; UI dropdowns fed from a stale choices list.","solutions":["Read the `{expenditure_choices}` list embedded in the error message and pass one of those exact values.","Programmatically: `from openbb_imf.models.consumer_price_index import expenditure_choices` and validate/select from it.","Use lowercase snake_case tokens; the validator checks lowercase membership first.","Upgrade openbb-imf if the category was renamed in a newer provider version."],"exampleFix":"# before\nres = obb.economy.cpi(provider='imf', country='USA', expenditure='food')\n\n# after\nres = obb.economy.cpi(provider='imf', country='USA', expenditure='food_and_non_alcoholic_beverages')","handlingStrategy":"validation","validationCode":"from openbb_imf.models.consumer_price_index import expenditure_choices\n\ndef validate_cpi_expenditure(raw: str) -> str:\n    tokens = [e.replace(' ', '_').lower() for e in raw.split(',')]\n    bad = [e for e in tokens if e not in expenditure_choices]\n    if bad:\n        raise ValueError(f'Invalid expenditure(s) {bad}; valid: {sorted(expenditure_choices)}')\n    return ','.join(tokens)","typeGuard":"from openbb_imf.models.consumer_price_index import expenditure_choices\n\ndef is_valid_expenditure(e: str) -> bool:\n    return e.replace(' ', '_').lower() in expenditure_choices","tryCatchPattern":null,"preventionTips":["Copy category names from the error message — it embeds the authoritative choices list.","Feed UI dropdowns from expenditure_choices at runtime instead of a hardcoded list."],"tags":["imf","openbb","cpi","validation","enum","pydantic"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}