tiangolo/fastapi · error · RuntimeError
No github event file available at: {settings.github_event_pa
Error message
No github event file available at: {settings.github_event_path} What it means
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.
Source
Thrown at scripts/notify_translations.py:316
query=update_comment_mutation,
comment_id=comment_id,
body=body,
)
response = UpdateCommentResponse.model_validate(data)
return response.data.updateDiscussionComment.comment
def main() -> None:
settings = Settings()
if settings.debug:
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.INFO)
logging.debug(f"Using config: {settings.model_dump_json()}")
g = Github(settings.github_token.get_secret_value())
repo = g.get_repo(settings.github_repository)
if not settings.github_event_path.is_file():
raise RuntimeError(
f"No github event file available at: {settings.github_event_path}"
)
contents = settings.github_event_path.read_text("utf-8")
github_event = PartialGitHubEvent.model_validate_json(contents)
logging.info(f"Using GitHub event: {github_event}")
number = (
github_event.pull_request and github_event.pull_request.number
) or settings.number
if number is None:
raise RuntimeError("No PR number available")
number = cast(int, number)
# Avoid race conditions with multiple labels
sleep_time = random.random() * 10 # random number between 0 and 10 seconds
logging.info(
f"Sleeping for {sleep_time} seconds to avoid "
"race conditions and multiple comments"
)View on GitHub (pinned to 3e8d1526d8)
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.
Example fix
# before — running locally with no event file python scripts/notify_translations.py # after — point at a saved PR event payload GITHUB_EVENT_PATH=./pr_event.json GITHUB_REPOSITORY=fastapi/fastapi GITHUB_TOKEN=*** python scripts/notify_translations.py
Defensive patterns
Strategy: validation
Validate before calling
import os
from pathlib import Path
def event_path_ok() -> bool:
p = os.environ.get("GITHUB_EVENT_PATH")
return bool(p) and Path(p).is_file() Try / catch
if not settings.github_event_path.is_file():
logging.error(f"Missing event file at {settings.github_event_path}")
sys.exit(1) Prevention
- 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.
When it happens
Trigger: 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().
Common situations: 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.
Related errors
- No PR number available
- Number of code include placeholders does not match the numbe
- Number of headers with permalinks does not match the number
- Header levels do not match between document and original doc
- Number of markdown links does not match the number in the or
AI-assisted analysis of tiangolo/fastapi@3e8d1526d8 (2026-08-11).
Data as JSON: /api/errors/cbbd834659443b3e.
Report an issue: GitHub.