Repository navigation
Skip quality-check annotations when XLIFF target is missing - #1109
ehoogerbeets wants to merge 2 commits into
Conversation
Prevents NPEs during drop import for trans-units with no <target> element so the existing import skip path can run. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
File: webapp/src/main/java/com/box/l10n/mojito/service/assetintegritychecker/integritychecker/TextUnitIntegrityCheckStep.java, lines 73-91 (related: webapp/src/test/java/com/box/l10n/mojito/service/tm/TMServiceTest.java, lines 584-643)
This fixes the NPE in QualityCheckStep, but TextUnitIntegrityCheckStep runs earlier in the same updateTMWithXliff pipeline and dereferences the same missing target: target.toString() at line 82 (and new TMTextUnitVariantCommentAnnotations(target) at line 91). For any repository that has text-unit integrity checkers configured for the asset extension, a trans-unit without will still NPE there, before the import step's "Target missing ... Skipping it" handling is reached.
The new test doesn't catch this because createTestData() creates a repository with no integrity checkers, so the checker loop never runs.
Suggest:
- In TextUnitIntegrityCheckStep.handleTextUnit, skip the integrity check (debug log + continue) when
target == null, same as in QualityCheckStep. - Extend the test (or add a second one) so the repository has at least one text-unit integrity checker for the "xliff" extension (e.g. via repositoryService with an AssetIntegrityChecker), so the whole pipeline is exercised with a missing target.
There was a problem hiding this comment.
File: webapp/src/test/java/com/box/l10n/mojito/service/tm/TMServiceTest.java, lines 631-642
The test proves no exception and that only one variant is imported, but it doesn't verify that the skipped unit is reported back to the user. Since the point of the fix is to let AbstractImportTranslationsStep's "Target missing" path run, consider asserting on the returned XLIFF, e.g.:
assertTrue(updateResult.getXliffContent().contains(
"Target missing for text unit with id: " + emptySourceTmTextUnit.getId()));
That way a regression that silently drops the unit (with no import note) would fail the test.
Summary
<target>(common when source is empty): quality check no longer NPEs on OkapiMISSING_TARGETTU.Test plan
TMServiceTest#testUpdateTMWithLocalizedXLIFFMissingTargetDoesNotThrowTMServiceTest#testUpdateTMWithLocalizedXLIFFWithQualityCheckErrors(existing quality-check path still works)<source />and no<target>and confirm the file import completes without NPEMade with Cursor