crewAIInc/crewAI · error · ValueError

Project name '{name}' would generate invalid Python module n

Error message

Project name '{name}' would generate invalid Python module name '{folder_name}'

What it means

Printed by PlusAPIMixin._validate_response when the CrewAI+ / Enterprise API returns a body that is not valid JSON (response.json() raises JSONDecodeError/ValueError). The CLI prints the status code and raw body, then raises SystemExit, aborting the deploy/plus command. Note the message itself contains a doubled 'failed' — it is cosmetic in the source.

Source

Thrown at lib/cli/src/crewai_cli/create_crew.py:81

        )

    if not folder_name:
        raise ValueError(
            f"Project name '{name}' contains no valid characters for a Python module name"
        )

    if folder_name[0].isdigit():
        raise ValueError(
            f"Project name '{name}' would generate folder name '{folder_name}' which cannot start with a digit (invalid Python module name)"
        )

    if keyword.iskeyword(folder_name):
        raise ValueError(
            f"Project name '{name}' would generate folder name '{folder_name}' which is a reserved Python keyword"
        )

    if not folder_name.isidentifier():
        raise ValueError(
            f"Project name '{name}' would generate invalid Python module name '{folder_name}'"
        )

    reserved_names = get_reserved_script_names()
    if folder_name in reserved_names:
        raise ValueError(
            f"Project name '{name}' would generate folder name '{folder_name}' which is reserved. "
            f"Reserved names are: {', '.join(sorted(reserved_names))}. "
            "Please choose a different name."
        )

    class_name = name.replace("_", " ").replace("-", " ").title().replace(" ", "")

    class_name = re.sub(r"[^a-zA-Z0-9_]", "", class_name)

    if not class_name:
        raise ValueError(
            f"Project name '{name}' contains no valid characters for a Python class name"

View on GitHub (pinned to 754d7323be)

Solutions

  1. Read the printed status code and raw response body in the CLI output — they identify the intercepting layer (gateway, SSO, proxy)
  2. If the body is a login/redirect page, run 'crewai login' again to refresh the token
  3. Retry after confirming the CrewAI+ service status if a 502/503 maintenance page is shown
  4. Update the CLI (pip install -U crewai) in case API routes changed between CLI and server versions

Example fix

// before
Status Code: 502
Response:
<html>Bad Gateway</html>   // proxy/gateway returned non-JSON

// after (after service recovered / re-login)
Status Code: 200
Response parsed as JSON; command proceeds
Defensive patterns

Strategy: try-catch

Try / catch

# In code driving the Plus API directly:
import httpx

r = await client.post(url, ...)
try:
    payload = r.json()
except (ValueError, httpx.DecodingError):
    # non-JSON body: gateway/SSO interception — surface status + snippet
    raise UpstreamNotJsonError(r.status_code, r.text[:200]) from None

Prevention

When it happens

Trigger: Any Plus API call whose response is HTML (auth proxy error page, 502 gateway page), plain text, or empty while claiming JSON — e.g. token expired so an SSO gateway returns an HTML redirect page, or the API endpoint is fronted by a proxy that returns a non-JSON error (command.py:53-63).

Common situations: Expired CrewAI+ session token causing an identity proxy to return HTML; transient gateway 502/503 with HTML body; corporate proxy intercepting the request; region/outage serving a maintenance page; CLI version pointing at a changed API route.

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/5925373f2aa6b141. Report an issue: GitHub.