{"record":{"id":"cbbd834659443b3e","repo":"tiangolo/fastapi","slug":"no-github-event-file-available-at-settings-githu","errorCode":null,"errorMessage":"No github event file available at: {settings.github_event_path}","messagePattern":"No github event file available at: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"scripts/notify_translations.py","lineNumber":316,"sourceCode":"        query=update_comment_mutation,\n        comment_id=comment_id,\n        body=body,\n    )\n    response = UpdateCommentResponse.model_validate(data)\n    return response.data.updateDiscussionComment.comment\n\n\ndef main() -> None:\n    settings = Settings()\n    if settings.debug:\n        logging.basicConfig(level=logging.DEBUG)\n    else:\n        logging.basicConfig(level=logging.INFO)\n    logging.debug(f\"Using config: {settings.model_dump_json()}\")\n    g = Github(settings.github_token.get_secret_value())\n    repo = g.get_repo(settings.github_repository)\n    if not settings.github_event_path.is_file():\n        raise RuntimeError(\n            f\"No github event file available at: {settings.github_event_path}\"\n        )\n    contents = settings.github_event_path.read_text(\"utf-8\")\n    github_event = PartialGitHubEvent.model_validate_json(contents)\n    logging.info(f\"Using GitHub event: {github_event}\")\n    number = (\n        github_event.pull_request and github_event.pull_request.number\n    ) or settings.number\n    if number is None:\n        raise RuntimeError(\"No PR number available\")\n    number = cast(int, number)\n\n    # Avoid race conditions with multiple labels\n    sleep_time = random.random() * 10  # random number between 0 and 10 seconds\n    logging.info(\n        f\"Sleeping for {sleep_time} seconds to avoid \"\n        \"race conditions and multiple comments\"\n    )","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/tiangolo/fastapi/blob/3e8d1526d83a90aaf7d6eb6dc682bf150f180b25/scripts/notify_translations.py#L298-L334","documentation":"Raised by notify_translations.main() at scripts/notify_translations.py:316 when settings.github_event_path does not point to an existing file. The script reads the GitHub Actions event payload from that path (set by GitHub Actions as GITHUB_EVENT_PATH) to discover the triggering pull request. Without it the run cannot determine which PR to act on.","triggerScenarios":"Running scripts/notify_translations.py outside GitHub Actions without setting GITHUB_EVENT_PATH, or in an action that does not populate it (e.g. workflow_dispatch without an event payload). Fires at scripts/notify_translations.py:315 where it checks settings.github_event_path.is_file().","commonSituations":"Local debugging run with no env var. Wrong job trigger (schedule, repository_dispatch) where GITHUB_EVENT_PATH still exists but is empty or stale — here it is genuinely absent. Runner environment corruption where the event file was deleted.","solutions":["Run the script only inside a pull_request / pull_request_target GitHub Actions job where GITHUB_EVENT_PATH is populated.","For local testing, export GITHUB_EVENT_PATH pointing to a saved PR event JSON and set the other Settings env vars (GITHUB_REPOSITORY, GITHUB_TOKEN).","If the runner lost the file, re-run the job on a fresh runner."],"exampleFix":"# before — running locally with no event file\npython scripts/notify_translations.py\n# after — point at a saved PR event payload\nGITHUB_EVENT_PATH=./pr_event.json GITHUB_REPOSITORY=fastapi/fastapi GITHUB_TOKEN=*** python scripts/notify_translations.py","handlingStrategy":"validation","validationCode":"import os\nfrom pathlib import Path\n\ndef event_path_ok() -> bool:\n    p = os.environ.get(\"GITHUB_EVENT_PATH\")\n    return bool(p) and Path(p).is_file()","typeGuard":null,"tryCatchPattern":"if not settings.github_event_path.is_file():\n    logging.error(f\"Missing event file at {settings.github_event_path}\")\n    sys.exit(1)","preventionTips":["Only run notify_translations in pull_request / pull_request_target jobs.","For local runs, export GITHUB_EVENT_PATH pointing at a saved PR event JSON.","Document the required env vars (GITHUB_EVENT_PATH, GITHUB_REPOSITORY, GITHUB_TOKEN) in the workflow."],"tags":["github","ci","environment","validation"],"backgroundTag":null,"analyzedSha":"3e8d1526d83a90aaf7d6eb6dc682bf150f180b25","analyzedAt":"2026-08-11T02:34:52.986Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}