crewAIInc/crewAI · error · ValueError

'{folder_name}' is a reserved Python keyword

Error message

'{folder_name}' is a reserved Python keyword

What it means

Raised by _check_index_exists when scoped_index is true and index_name is not among the Search indexes returned by scope.search_indexes().get_all_indexes(). Scoped Search indexes live inside a specific bucket.scope, so the tool checks the scope's index list first (the cluster-level branch raises the same message at line 128).

Source

Thrown at lib/cli/src/crewai_cli/create_json_crew.py:891

    dmn_mode = is_dmn_mode_enabled()
    if not dmn_mode:
        enable_prompt_line_editing()

    name = name.rstrip("/")
    if not name.strip():
        raise ValueError("Project name cannot be empty")

    folder_name = name.replace(" ", "_").replace("-", "_").lower()
    folder_name = re.sub(r"[^a-zA-Z0-9_]", "", folder_name)

    if not folder_name or folder_name[0].isdigit():
        raise ValueError(
            f"Project name '{name}' produces invalid folder name '{folder_name}'"
        )

    if keyword.iskeyword(folder_name):
        raise ValueError(f"'{folder_name}' is a reserved Python keyword")

    folder_path = Path(folder_name)
    if folder_path.exists():
        if dmn_mode:
            raise click.ClickException(f"Folder {folder_name} already exists.")
        if not click.confirm(f"Folder {folder_name} already exists. Override?"):
            click.secho("Cancelled.", fg="yellow")
            sys.exit(0)
        shutil.rmtree(folder_path)

    click.echo()
    click.secho(f"  Creating crew: {name}", fg="green", bold=True)

    default_llm = _default_model_for_provider(provider)
    if dmn_mode:
        agents, tasks, crew_settings = _default_agents_and_tasks(default_llm)
    else:
        agents, tasks, crew_settings = _wizard_agents_and_tasks(

View on GitHub (pinned to 754d7323be)

Solutions

  1. Create the Search index in the right bucket/scope (Couchbase UI -> Search -> Add index, or the index REST API) with exactly index_name.
  2. If the index exists at cluster level, pass scoped_index=False (and a cluster connection) instead.
  3. List indexes to confirm: [i.name for i in scope.search_indexes().get_all_indexes()].

Example fix

# before
tool = CouchbaseFTSVectorSearchTool(bucket_name='travel', scope_name='inventory', collection_name='hotel', index_name='hotel_idx', scoped_index=True)  # ValueError
# after
# create scoped index 'hotel_idx' on travel.inventory.hotel first, then:
tool = CouchbaseFTSVectorSearchTool(bucket_name='travel', scope_name='inventory', collection_name='hotel', index_name='hotel_idx', scoped_index=True)
Defensive patterns

Strategy: validation

Validate before calling

if scoped_index:
    names = {i.name for i in cluster.bucket(bucket_name).scope(scope_name).search_indexes().get_all_indexes()}
    if index_name not in names:
        raise ValueError(f"index '{index_name}' not found in scope '{scope_name}'; available: {sorted(names)}")

Prevention

When it happens

Trigger: Initializing the tool with scoped_index=True and an index_name that was never created at that scope, or an index created at cluster level while the tool looks in the scope.

Common situations: Index created in the Couchbase UI under a different bucket/scope, index name typo, index creation not yet propagated, or scoped_index mismatch with where the index actually lives.

Related errors


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