bito-code-review[bot] commented on code in PR #41465:
URL: https://github.com/apache/superset/pull/41465#discussion_r3484667484


##########
scripts/translations/build_translation_index.py:
##########
@@ -86,7 +86,17 @@ def build_index(translations_dir: Path) -> dict[str, Any]:
 
     for lang in langs:
         po_path = translations_dir / lang / "LC_MESSAGES" / "messages.po"
-        cat = polib.pofile(str(po_path))
+        try:
+            cat = polib.pofile(str(po_path))
+        except OSError as exc:
+            # A single malformed catalog (e.g. an unescaped quote) shouldn't
+            # block backfilling every other language. Skip it with a loud
+            # warning so the corrupt file gets fixed separately.
+            print(
+                f"WARNING: skipping {lang} — could not parse {po_path}: {exc}",
+                file=sys.stderr,
+            )
+            continue

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing error-path test coverage</b></div>
   <div id="fix">
   
   The new error-handling block (lines 89-99) catches malformed PO files and 
skips the language, but this path is not covered by existing tests. Without a 
test, future changes to polib's exception behavior or the catch logic could 
regress silently. Add a test that writes a corrupt PO file alongside a valid 
one and asserts the valid language's translations are still indexed.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #a0ab2f</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to