reflex-dev/reflex · error · ValueError
app_name should be a string
Error message
app_name should be a string
What it means
Raised by create_app() when app_name is not a non-empty string. The name becomes the 'name' field of the POST /api/v1/apps payload, so the library validates it up front rather than letting the backend reject the request. Typically hit when passing None, an empty string, or a non-str value from config or CLI options.
Source
Thrown at packages/reflex-hosting-cli/src/reflex_cli/utils/hosting.py:956
app_name: The name of the application.
description: The description of the application.
project_id: The ID of the project to associate the application with.
client: The authenticated client
provider: The hosting provider to pin the app to (e.g. "gcp"). ``None``
keeps the Reflex Cloud default.
Returns:
dict: The created application details as a dictionary.
Raises:
NotAuthenticatedError: If the token is not valid.
ValueError: If forbidden.
"""
import httpx
if not isinstance(app_name, str) or not app_name:
raise ValueError("app_name should be a string")
if not isinstance(client, AuthenticatedClient):
raise NotAuthenticatedError("not authenticated")
payload: dict[str, Any] = {
"name": app_name,
"description": description,
"project": project_id,
}
if provider is not None:
payload["provider"] = provider
response = httpx.post(
urljoin(constants.Hosting.HOSTING_SERVICE, "/api/v1/apps/"),
json=payload,
headers=authorization_header(client.token),
timeout=constants.Hosting.TIMEOUT,
)
if response.status_code == HTTPStatus.FORBIDDEN:
logger.debug(f"Server responded with 403: {response.text}")
raise ValueError(f"{response.text}")View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Set a valid non-empty string app name in rxconfig.yaml (app_name = "my-app") or pass it explicitly to create_app()
- Check the value is truthy before deploying: assert isinstance(app_name, str) and app_name
- If the name comes from user input, strip and validate it before calling create_app
Example fix
# before app = create_app(client, app_name=None, project_id=proj_id) # after app_name = config.app_name or "my-default-app" app = create_app(client, app_name=app_name, project_id=proj_id)
Defensive patterns
Strategy: validation
Validate before calling
app_name = (app_name or config.app_name or "").strip()
if not app_name:
raise ValueError("app_name is required before deploy")
create_app(client, app_name=app_name, project_id=project_id) Type guard
def is_valid_app_name(name: object) -> bool:
return isinstance(name, str) and bool(name.strip()) Try / catch
try:
create_app(client, app_name, project_id)
except ValueError as ex:
if "app_name" in str(ex):
app_name = config.app_name
create_app(client, app_name, project_id)
else:
raise Prevention
- Set app_name in rxconfig.yaml so deploy always has a valid name
- Validate names at the edge (CLI/config load), not at the API boundary
When it happens
Trigger: Calling create_app() (used by deploy and directly in tests) with app_name=None, "", or a non-string — e.g. reading rxconfig.yaml's app_name into the wrong variable, or a CLI flag left unset.
Common situations: rxconfig.yaml has a missing/empty app_name; scripted deploy passes a falsy name; refactoring renamed the variable holding the name.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- app_id should be a string
- bad hostname provided
- project search failed: {ex_details}
- detail
- deployment failed: {ex_details}
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/0791639cbcf80efa.
Report an issue: GitHub.