{"record":{"id":"a6d571ca104dcf18","repo":"reflex-dev/reflex","slug":"app-id-should-be-a-string","errorCode":null,"errorMessage":"app_id should be a string","messagePattern":"app_id should be a string","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-hosting-cli/src/reflex_cli/utils/hosting.py","lineNumber":912,"sourceCode":"    Args:\n        app_id: The ID of the application to retrieve.\n        client: The authenticated client\n\n    Returns:\n        dict: The application details as a dictionary.\n\n    Raises:\n        NotAuthenticatedError: If the token is not valid.\n        GetAppError: If the request to get the app fails.\n        ValueError: If the app_id is not valid.\n\n    \"\"\"\n    import httpx\n\n    if not isinstance(client, AuthenticatedClient):\n        raise NotAuthenticatedError(\"not authenticated\")\n    if not isinstance(app_id, str) or not app_id:\n        raise ValueError(\"app_id should be a string\")\n    response = httpx.get(\n        urljoin(constants.Hosting.HOSTING_SERVICE, f\"/api/v1/apps/{app_id}\"),\n        headers=authorization_header(client.token),\n        timeout=constants.Hosting.TIMEOUT,\n    )\n    try:\n        response.raise_for_status()\n    except httpx.HTTPStatusError as ex:\n        try:\n            raise GetAppError(ex.response.json().get(\"detail\")) from ex\n        except json.JSONDecodeError:\n            raise GetAppError(ex.response.text) from ex\n    return response.json()\n\n\ndef create_app(\n    app_name: str,\n    client: AuthenticatedClient,","sourceCodeStart":894,"sourceCodeEnd":930,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-hosting-cli/src/reflex_cli/utils/hosting.py#L894-L930","documentation":"Raised by get_app() when app_id is not a non-empty string. The function validates its input before hitting GET /api/v1/apps/{app_id}, because an invalid id would either produce a meaningless URL or an unhelpful 404/422 from the server. Common causes: passing the app dict instead of its 'id' key, an int id, or None.","triggerScenarios":"Calling get_app() (or delete_app / get_app_logs) with app_id=None, an int, or \"\" — e.g. get_app(client, app) where app is the dict returned by create_app instead of app[\"id\"].","commonSituations":"Forgetting to extract the 'id' field from an app object/dict; passing a UUID object instead of str(uuid); passing an empty variable from a failed lookup upstream.","solutions":["Pass the app's id string: get_app(client, app_id=app['id']) or str(app_id)","If the id comes from user input or another API, check it is a non-empty str before calling","For UUID objects, convert with str() first"],"exampleFix":"# before\napp = get_app(client, app_id=app_json)  # dict passed\n\n# after\napp = get_app(client, app_id=app_json[\"id\"])  # id string","handlingStrategy":"type-guard","validationCode":"if not isinstance(app_id, str) or not app_id:\n    raise ValueError(f\"app_id must be a non-empty str, got {app_id!r}\")\napp = get_app(client, app_id)","typeGuard":"def is_valid_app_id(app_id: object) -> bool:\n    return isinstance(app_id, str) and bool(app_id)","tryCatchPattern":"try:\n    get_app(client, app_id)\nexcept ValueError as ex:\n    if \"app_id\" in str(ex):\n        app_id = str(app[\"id\"])\n        get_app(client, app_id)\n    else:\n        raise","preventionTips":["Always extract the 'id' key from app dicts/objects before passing to get_app/delete_app/get_app_logs","Type-annotate parameters as str so type checkers catch dict/None misuse early","Convert UUID objects with str() before calling"],"tags":["validation","argument","hosting","reflex-cli"],"backgroundTag":"invalid-argument-value","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}