{"record":{"id":"1bb05bd314647591","repo":"zed-industries/zed","slug":"option-option-name-not-found-in-field-field-1bb05b","errorCode":null,"errorMessage":"Option '{option_name}' not found in field '{field_name}'","messagePattern":"Option '(.+?)' not found in field '(.+?)'","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"script/github-guild-board.py","lineNumber":304,"sourceCode":"    )\n    node = data.get(\"node\") or {}\n    for item in (node.get(\"projectItems\") or {}).get(\"nodes\", []):\n        if item[\"project\"][\"id\"] == project_id:\n            return item\n    return None\n\n\ndef set_project_field(project, item_id, field_name, option_name):\n    field = next(\n        (f for f in project[\"fields\"][\"nodes\"] if f.get(\"name\") == field_name), None\n    )\n    if not field:\n        raise RuntimeError(f\"Field '{field_name}' not found on board\")\n    option_id = next(\n        (o[\"id\"] for o in field.get(\"options\", []) if o[\"name\"] == option_name), None\n    )\n    if not option_id:\n        raise RuntimeError(f\"Option '{option_name}' not found in field '{field_name}'\")\n    github_graphql(\n        \"\"\"\n        mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) {\n          updateProjectV2ItemFieldValue(input: {\n            projectId: $projectId, itemId: $itemId, fieldId: $fieldId,\n            value: { singleSelectOptionId: $optionId }\n          }) { projectV2Item { id } }\n        }\n        \"\"\",\n        {\n            \"projectId\": project[\"id\"],\n            \"itemId\": item_id,\n            \"fieldId\": field[\"id\"],\n            \"optionId\": option_id,\n        },\n    )\n\n","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/script/github-guild-board.py#L286-L322","documentation":"After the field is found, set_project_field needs the id of the single-select option whose name equals option_name; when no option matches it raises before sending updateProjectV2ItemFieldValue. The mutation only accepts option ids, so a name the field does not define cannot be written.","triggerScenarios":"The guild board's Status option vocabulary differs from what the script passes: an option like \"In Progress\" was renamed or never existed on this board, or the script maps a state to an option added only on another project.","commonSituations":"Workflow status renames on the board; new states added to the script but not to the field's option list; whitespace or case drift between script strings and board options.","solutions":["Read field['options'] (already fetched) and update the script to pass an option that exists","Add the missing option to the single-select field on the project if the state is legitimate","Normalize case/whitespace when comparing option names","Validate the full expected option set at startup"],"exampleFix":"// before\noption_id = next((o[\"id\"] for o in field.get(\"options\", []) if o[\"name\"] == option_name), None)\nif not option_id:\n    raise RuntimeError(f\"Option '{option_name}' not found in field '{field_name}'\")\n\n// after\noption_id = next(\n    (o[\"id\"] for o in field.get(\"options\", []) if o[\"name\"].strip().lower() == option_name.strip().lower()),\n    None,\n)\nif not option_id:\n    available = [o[\"name\"] for o in field.get(\"options\", [])]\n    raise RuntimeError(f\"Option '{option_name}' not found in field '{field_name}'; available: {available}\")","handlingStrategy":"validation","validationCode":"def field_has_option(field: dict, option_name: str) -> bool:\n    return any(o.get(\"name\") == option_name for o in field.get(\"options\", []))","typeGuard":"def option_id_if_present(field: dict, option_name: str) -> str | None:\n    return next((o[\"id\"] for o in field.get(\"options\", []) if o.get(\"name\") == option_name), None)","tryCatchPattern":"try:\n    set_project_field(project, item_id, STATUS_FIELD, option)\nexcept RuntimeError as exc:\n    if \"not found in field\" in str(exc):\n        log(f\"Option drift: {exc}\")\n    else:\n        raise","preventionTips":["Validate the full option set after loading the project","Add new options to the board before deploying script versions referencing them","Normalize case and whitespace in option comparisons","Print the field's option list on mismatch"],"tags":["github-projects","graphql","config-drift","python"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}