Skip to content

Skip quality-check annotations when XLIFF target is missing - #1109

Open
ehoogerbeets wants to merge 2 commits into
box:masterfrom
ehoogerbeets:fix-empty-xliff-trans-units
Open

ehoogerbeets wants to merge 2 commits into
box:masterfrom
ehoogerbeets:fix-empty-xliff-trans-units

Conversation

@ehoogerbeets

Copy link
Copy Markdown
Contributor

Summary

  • Harden drop/XLIFF import against trans-units that omit <target> (common when source is empty): quality check no longer NPEs on Okapi MISSING_TARGETTU.
  • Missing-target units are skipped by the existing import path; other units in the same file still import.
  • Adds a regression test covering empty source + no target alongside a normal unit.

Test plan

  • TMServiceTest#testUpdateTMWithLocalizedXLIFFMissingTargetDoesNotThrow
  • TMServiceTest#testUpdateTMWithLocalizedXLIFFWithQualityCheckErrors (existing quality-check path still works)
  • Import a localized XLIFF that includes a trans-unit with empty <source /> and no <target> and confirm the file import completes without NPE

Made with Cursor

ehoogerbeets and others added 2 commits October 27, 2026 09:34
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>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants