A translation that failed validation three times is written to disk anyway

Offen Anfängerfreundlich
#16,812 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
85/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
fastapi, python

Rechercherichtung

Lies die Wiederholungs- und Validierungsschleife in scripts/translate.py:182-186, insbesondere den for…else-Zweig und den anschließenden Schreibvorgang. Führe zunächst die Reproduktion aus dem Issue aus, um zu bestätigen, dass die fehlgeschlagene Übersetzung weiterhin geschrieben wird. Die Korrektur ist abgeschlossen, wenn drei Validierungsfehler den Schreibvorgang verhindern und der Befehl einen Fehler meldet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

A translation that failed validation three times is written to disk anyway

Code: scripts/translate.py:186 (as of 05e6df7e906c)

  • A translation that failed validation three times is written to disk anyway
    • File: scripts/translate.py:182-186
    • Feature: LLM translation pipeline (retry/validation loop in translate_page)
    • Symptom: log prints Translation failed ... after 3 attempts then Saving translation to ...; the rejected text lands on disk and the command exits 0 — runtime-verified: FILE WRITTEN AFTER 3 FAILED CHECKS: True 'traduccion rota\n'.
    • Root cause: the for…else branch at :182-183 only prints; control falls through to out_path.write_text(out_content) at :186.
    • Impact: a translation the tool itself rejected is committed and PR'd by the CI "Create pull request" step with green CI; the only signal is a log line.
    • Fix shape: raise (or return) before the write in the for…else branch at scripts/translate.py:182-186.
Reproduction
import sys, types, tempfile, os; sys.path.insert(0, "/Volumes/docker-ssd/Migration/Development/audits/campaign/work/r0003")
from pathlib import Path
for n in ("typer", "github", "pydantic_ai", "rich"): sys.modules[n] = types.ModuleType(n)
T = sys.modules["typer"]; T.Typer = lambda: type("T", (), {"command": lambda s, f=None, **k: f or (lambda g: g)})(); T.Option = T.Argument = lambda **k: None
sys.modules["rich"].print = print; sys.modules["github"].Github = lambda *a, **k: None
sys.modules["pydantic_ai"].Agent = lambda *a, **k: type("A", (), {"run_sync": lambda s, p: type("R", (), {"output": "traduccion rota"})()})()
from scripts import translate
tmp = tempfile.mkdtemp(); os.chdir(tmp); Path("docs/en/docs").mkdir(parents=True); Path("docs/en/docs/index.md").write_text("# Hi\n"); Path("docs/es").mkdir(parents=True); Path("docs/es/llm-prompt.md").write_text("")
translate.get_langs = lambda: {"es": "Spanish"}; translate.check_translation = lambda **k: (_ for _ in ()).throw(ValueError("boom"))
translate.translate_page(language="es", en_path=Path("docs/en/docs/index.md"))
print("FILE WRITTEN AFTER 3 FAILED CHECKS:", Path("docs/es/docs/index.md").exists(), repr(Path("docs/es/docs/index.md").read_text() if Path("docs/es/docs/index.md").exists() else ""))

/tmp/r0003venv/bin/python zzcampaign_repro-2.py → exit 0

Translating docs/en/docs/index.md to es (Spanish)
Running agent for docs/es/docs/index.md (attempt 1/3)
Translation check failed on attempt 1/3: boom
Running agent for docs/es/docs/index.md (attempt 2/3)
Translation check failed on attempt 2/3: boom
Running agent for docs/es/docs/index.md (attempt 3/3)
Translation check failed on attempt 3/3: boom
Translation failed for docs/es/docs/index.md after 3 attempts
Saving translation to docs/es/docs/index.md
FILE WRITTEN AFTER 3 FAILED CHECKS: True 'traduccion rota\n'
Environment
  • fastapi/fastapi @ 05e6df7e906c, Python
  • Found by a multi-lens automated audit; the snippet above was executed against this commit before filing.
Vorherrschende Sprache
Python
Sterne
105k
Forks
10.4k
Ø Merge
13 Std. 23 Min.
Gemergte PRs (30 T.)
95

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus fastapi/fastapi

Alle Issues in fastapi/fastapi

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.