stanford-oval/storm · error · RuntimeError

You must supply azure_ai_search_index_name or set environmen

Error message

You must supply azure_ai_search_index_name or set environment variable AZURE_AI_SEARCH_INDEX_NAME

What it means

Raised by AzureAISearchRM.__init__ when the search index name is neither passed as azure_ai_search_index_name nor available via the AZURE_AI_SEARCH_INDEX_NAME environment variable. The index identifies which document collection to query, so the constructor refuses to continue without it.

Source

Thrown at knowledge_storm/rm.py:1168

            )
        elif azure_ai_search_api_key:
            self.azure_ai_search_api_key = azure_ai_search_api_key
        else:
            self.azure_ai_search_api_key = os.environ["AZURE_AI_SEARCH_API_KEY"]

        if not azure_ai_search_url and not os.environ.get("AZURE_AI_SEARCH_URL"):
            raise RuntimeError(
                "You must supply azure_ai_search_url or set environment variable AZURE_AI_SEARCH_URL"
            )
        elif azure_ai_search_url:
            self.azure_ai_search_url = azure_ai_search_url
        else:
            self.azure_ai_search_url = os.environ["AZURE_AI_SEARCH_URL"]

        if not azure_ai_search_index_name and not os.environ.get(
            "AZURE_AI_SEARCH_INDEX_NAME"
        ):
            raise RuntimeError(
                "You must supply azure_ai_search_index_name or set environment variable AZURE_AI_SEARCH_INDEX_NAME"
            )
        elif azure_ai_search_index_name:
            self.azure_ai_search_index_name = azure_ai_search_index_name
        else:
            self.azure_ai_search_index_name = os.environ["AZURE_AI_SEARCH_INDEX_NAME"]

        self.usage = 0

        # If not None, is_valid_source shall be a function that takes a URL and returns a boolean.
        if is_valid_source:
            self.is_valid_source = is_valid_source
        else:
            self.is_valid_source = lambda x: True

    def get_usage_and_reset(self):
        usage = self.usage
        self.usage = 0

View on GitHub (pinned to fb951af774)

Solutions

  1. export AZURE_AI_SEARCH_INDEX_NAME="<your-index-name>"
  2. Or pass it explicitly: AzureAISearchRM(azure_ai_search_api_key=..., azure_ai_search_url=..., azure_ai_search_index_name="my-index")
  3. Verify the index exists in the Azure portal (Search service > Indexes) and matches the name you supply

Example fix

# before
rm = AzureAISearchRM(azure_ai_search_api_key=KEY, azure_ai_search_url=URL)

# after
rm = AzureAISearchRM(azure_ai_search_api_key=KEY, azure_ai_search_url=URL, azure_ai_search_index_name="my-index")
Defensive patterns

Strategy: validation

Validate before calling

import os

def has_azure_index_name(explicit=None):
    return bool(explicit or os.environ.get("AZURE_AI_SEARCH_INDEX_NAME"))

assert has_azure_index_name(), "Missing AZURE_AI_SEARCH_INDEX_NAME"

Try / catch

try:
    rm = AzureAISearchRM(azure_ai_search_api_key=K, azure_ai_search_url=U)
except RuntimeError as e:
    if "AZURE_AI_SEARCH_INDEX_NAME" in str(e):
        raise SystemExit("Set AZURE_AI_SEARCH_INDEX_NAME to an existing index")
    raise

Prevention

When it happens

Trigger: Constructing AzureAISearchRM with no azure_ai_search_index_name argument and no AZURE_AI_SEARCH_INDEX_NAME env var; this is the last of the three lazy config checks (key, url, index).

Common situations: Key and URL configured but index name forgotten; index name typo'd earlier so the developer removed it; multi-index deployments where the index name is only known per-environment and wasn't propagated to the container/CI env.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of stanford-oval/storm@fb951af774 (2026-08-28). Data as JSON: /api/errors/2553ac8e1c0bd3da. Report an issue: GitHub.