tiangolo/fastapi · error · RuntimeError
Could not find discussion for language: {lang}
Error message
Could not find discussion for language: {lang} What it means
Raised by notify_translations.main() at scripts/notify_translations.py:370 when a PR carries a lang-<code> label (e.g. lang-es) but no matching translation discussion exists in the GitHub Discussions translations category. The script builds lang_to_discussion_map from discussions carrying a lang-* label (scripts/notify_translations.py:352-358); a missing entry means there is nowhere to post the review notification, so it aborts rather than silently skip.
Source
Thrown at scripts/notify_translations.py:370
lang_to_discussion_map: dict[str, AllDiscussionsDiscussionNode] = {}
for discussion in discussions:
for edge in discussion.labels.edges:
label = edge.node.name
if label.startswith("lang-") and not label == lang_all_label:
lang = label[5:]
lang_to_discussion_map[lang] = discussion
logging.debug(f"Using translations map: {lang_to_discussion_map}")
# Messages to create or check
new_translation_message = f"Good news everyone! 😉 There's a new translation PR to be reviewed: #{pr.number} by @{pr.user.login}. 🎉 This requires 2 approvals from native speakers to be merged. 🤓"
done_translation_message = f"~There's a new translation PR to be reviewed: #{pr.number} by @{pr.user.login}~ Good job! This is done. 🍰☕"
# Normally only one language, but still
for lang in langs:
if lang not in lang_to_discussion_map:
log_message = f"Could not find discussion for language: {lang}"
logging.error(log_message)
raise RuntimeError(log_message)
discussion = lang_to_discussion_map[lang]
logging.info(
f"Found a translation discussion for language: {lang} in discussion: #{discussion.number}"
)
already_notified_comment: Comment | None = None
already_done_comment: Comment | None = None
logging.info(
f"Checking current comments in discussion: #{discussion.number} to see if already notified about this PR: #{pr.number}"
)
comments = get_graphql_translation_discussion_comments(
settings=settings, discussion_number=discussion.number
)
for comment in comments:
if new_translation_message in comment.body:
already_notified_comment = comment
elif done_translation_message in comment.body:View on GitHub (pinned to 3e8d1526d8)
Solutions
- Create a discussion in the translations category and label it with the matching lang-<code> label.
- Confirm the lang-<code> label on the PR exactly matches the label on the discussion (case-sensitive).
- If there are more than 100 discussions, add pagination to all_discussions_query (currently capped at first: 100).
- Re-run the notify job once the discussion exists.
Defensive patterns
Strategy: try-catch
Try / catch
if lang not in lang_to_discussion_map:
logging.warning(
f"No discussion for lang-{lang}; create one and label it, "
"then re-run the job"
)
continue # or sys.exit(1) if hard-fail is desired Prevention
- Before labeling a PR with a new lang-XX label, create the matching discussion with the same label.
- Paginate the discussions query if the category may exceed 100 entries.
- Monitor CI for this error when onboarding a new translation language.
When it happens
Trigger: A maintainer labels a PR with a new lang-XX label for a language whose discussion thread has not been created yet, or the discussion exists but lacks the matching lang-XX label. Also if the discussions query returned only the first 100 and the relevant discussion is beyond that page.
Common situations: New translation language added before its discussion category thread exists. Discussion's lang-XX label was renamed or removed. Pagination ceiling: more than 100 discussions in the category (all_discussions_query uses first: 100).
Related errors
- 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
- Number of HTML links does not match the number in the origin
AI-assisted analysis of tiangolo/fastapi@3e8d1526d8 (2026-08-11).
Data as JSON: /api/errors/646451177ae45751.
Report an issue: GitHub.