{"record":{"id":"646451177ae45751","repo":"tiangolo/fastapi","slug":"could-not-find-discussion-for-language-lang","errorCode":null,"errorMessage":"Could not find discussion for language: {lang}","messagePattern":"Could not find discussion for language: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"scripts/notify_translations.py","lineNumber":370,"sourceCode":"    lang_to_discussion_map: dict[str, AllDiscussionsDiscussionNode] = {}\n    for discussion in discussions:\n        for edge in discussion.labels.edges:\n            label = edge.node.name\n            if label.startswith(\"lang-\") and not label == lang_all_label:\n                lang = label[5:]\n                lang_to_discussion_map[lang] = discussion\n    logging.debug(f\"Using translations map: {lang_to_discussion_map}\")\n\n    # Messages to create or check\n    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. 🤓\"\n    done_translation_message = f\"~There's a new translation PR to be reviewed: #{pr.number} by @{pr.user.login}~ Good job! This is done. 🍰☕\"\n\n    # Normally only one language, but still\n    for lang in langs:\n        if lang not in lang_to_discussion_map:\n            log_message = f\"Could not find discussion for language: {lang}\"\n            logging.error(log_message)\n            raise RuntimeError(log_message)\n        discussion = lang_to_discussion_map[lang]\n        logging.info(\n            f\"Found a translation discussion for language: {lang} in discussion: #{discussion.number}\"\n        )\n\n        already_notified_comment: Comment | None = None\n        already_done_comment: Comment | None = None\n\n        logging.info(\n            f\"Checking current comments in discussion: #{discussion.number} to see if already notified about this PR: #{pr.number}\"\n        )\n        comments = get_graphql_translation_discussion_comments(\n            settings=settings, discussion_number=discussion.number\n        )\n        for comment in comments:\n            if new_translation_message in comment.body:\n                already_notified_comment = comment\n            elif done_translation_message in comment.body:","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/tiangolo/fastapi/blob/3e8d1526d83a90aaf7d6eb6dc682bf150f180b25/scripts/notify_translations.py#L352-L388","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if lang not in lang_to_discussion_map:\n    logging.warning(\n        f\"No discussion for lang-{lang}; create one and label it, \"\n        \"then re-run the job\"\n    )\n    continue  # or sys.exit(1) if hard-fail is desired","preventionTips":["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."],"tags":["github","translation","discussions","ci"],"backgroundTag":null,"analyzedSha":"3e8d1526d83a90aaf7d6eb6dc682bf150f180b25","analyzedAt":"2026-08-11T02:34:52.986Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}