apache/superset · error · ExtensionNameError

'{name}' is not a valid Python package name

Error message

'{name}' is not a valid Python package name

What it means

The final identifier check in validate_python_package_name: after replacing underscores with letters, the name must be fully alphanumeric — anything else (hyphens, spaces, dots, unicode punctuation) means it is not a valid snake_case Python package name. The full rejected name is echoed in the error.

Source

Thrown at superset-extensions-cli/src/superset_extensions_cli/utils.py:205

    """
    Validate Python package name (snake_case format).

    Raises:
        ExtensionNameError: If name is invalid
    """
    # Check if it starts with a number (invalid for Python identifiers)
    if name[0].isdigit():
        raise ExtensionNameError(f"Package name '{name}' cannot start with a number")

    # Check if the first part (before any underscore) is a Python keyword
    if (first_part := name.split("_")[0]) in PYTHON_KEYWORDS:
        raise ExtensionNameError(
            f"Package name cannot start with Python keyword '{first_part}'"
        )

    # Check if it's a valid Python identifier
    if not name.replace("_", "a").isalnum():
        raise ExtensionNameError(f"'{name}' is not a valid Python package name")


def validate_npm_package_name(name: str) -> None:
    """
    Validate npm package name (kebab-case format).

    Raises:
        ExtensionNameError: If name is invalid
    """
    if name.lower() in NPM_RESERVED:
        raise ExtensionNameError(f"'{name}' is a reserved npm package name")


def validate_publisher(publisher: str) -> None:
    """
    Validate publisher namespace format.

    Args:

View on GitHub (pinned to f4587218dd)

Solutions

  1. Use ASCII letters, digits and underscores/hyphens only: 'my-ext' or 'my_ext'.
  2. Replace unicode dashes/quotes pasted from rich text with plain ASCII.
  3. Quote CLI arguments properly so shell metacharacters are not embedded.

Example fix

# before
$ superset-extension new "my.ext"
# after
$ superset-extension new my_ext
Defensive patterns

Strategy: validation

Validate before calling

import re

PYTHON_PKG_OK = re.compile(r'^[A-Za-z][A-Za-z0-9_]*$')

def is_valid_python_package(name: str) -> bool:
    return bool(PYTHON_PKG_OK.match(name))

Try / catch

try:
    validate_python_package_name(name)
except ExtensionNameError as e:
    print(f'Invalid extension name: {e}')
    sys.exit(2)

Prevention

When it happens

Trigger: Passing a name with stray characters: 'my.ext', 'chart/viz', 'hello world', 'café-map', trailing symbols like 'auth!', or an empty string reaching the validator after other checks.

Common situations: Shell quoting issues introducing spaces/slashes; copy-paste names with unicode dashes (en/em dash) instead of ASCII hyphen expected before normalization; names containing dots from fully-qualified inputs.

Related errors


AI-assisted analysis of apache/superset@f4587218dd (2026-08-14). Data as JSON: /api/errors/7c3a1d2e905b880c. Report an issue: GitHub.