zed-industries/zed · error · RuntimeError

Option '{option_name}' not found in field '{field_name}'. Av

Error message

Option '{option_name}' not found in field '{field_name}'. Available: {available}

What it means

The single-select field lookup succeeded but none of its options equals option_name. The updateProjectV2ItemFieldValue mutation needs an option id, so an unknown option name cannot be written and the script aborts, listing the option names the field actually has. Like the field check, this is exact string matching and therefore sensitive to renames, case, and whitespace.

Source

Thrown at script/github-community-pr-board.py:563

            for option in field.get("options", []):
                if option["name"] == option_name:
                    option_id = option["id"]
                    break
            break

    if not field_id:
        available = [f["name"] for f in project["fields"]["nodes"] if "name" in f]
        raise RuntimeError(
            f"Field '{field_name}' not found on project. Available: {available}"
        )
    if not option_id:
        available = [
            opt["name"]
            for f in project["fields"]["nodes"]
            if f.get("name") == field_name
            for opt in f.get("options", [])
        ]
        raise RuntimeError(
            f"Option '{option_name}' not found in field '{field_name}'. "
            f"Available: {available}"
        )

    github_graphql(
        """
        mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) {
          updateProjectV2ItemFieldValue(input: {
            projectId: $projectId
            itemId: $itemId
            fieldId: $fieldId
            value: { singleSelectOptionId: $optionId }
          }) {
            projectV2Item { id }
          }
        }
        """,
        {

View on GitHub (pinned to bc538def45)

Solutions

  1. Pick the correct option from the Available list in the error and update the script's mapping
  2. If the new state is legitimate, add the option to the field on the GitHub project (board UI or API) first
  3. Normalize whitespace and case before comparing option names
  4. Assert the expected options exist at startup together with the field checks

Example fix

// before
for option in field.get("options", []):
    if option["name"] == option_name:
        option_id = option["id"]
        break

// after
for option in field.get("options", []):
    if option["name"].strip().lower() == option_name.strip().lower():
        option_id = option["id"]
        break
Defensive patterns

Strategy: validation

Validate before calling

def field_has_option(project: dict, field_name: str, option_name: str) -> bool:
    for field in project["fields"]["nodes"]:
        if field.get("name") == field_name:
            return any(o.get("name") == option_name for o in field.get("options", []))
    return False

Type guard

def is_valid_option(field: dict, option_name: str) -> bool:
    return any(o.get("name") == option_name for o in field.get("options", []))

Try / catch

try:
    set_field(project, item_id, STATUS_FIELD, option)
except RuntimeError as exc:
    if "not found in field" in str(exc):
        log(f"Option drift: {exc}; available statuses need a mapping update")
    else:
        raise

Prevention

When it happens

Trigger: set_field runs with option_name like "In Progress" while the board field's options are ["Todo", "In Review", "Done"]; the option was renamed or removed on the board; the script's state-to-option mapping contains a state never added to the field.

Common situations: Team renames workflow statuses; triage-state vocabulary changes without updating the board; typos or trailing whitespace differences ("Done " vs "Done").

Related errors


AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16). Data as JSON: /api/errors/91e131cdb9c996f5. Report an issue: GitHub.