Skip to content

Comments

fix(cli): guard against empty translations in PO loader#2000

Merged
cherkanovart merged 1 commit intomainfrom
fix/po-loader-empty-translations-crash
Feb 20, 2026
Merged

fix(cli): guard against empty translations in PO loader#2000
cherkanovart merged 1 commit intomainfrom
fix/po-loader-empty-translations-crash

Conversation

@cherkanovart
Copy link
Contributor

@cherkanovart cherkanovart commented Feb 20, 2026

Summary

  • Fix TypeError: Cannot convert undefined or null to object crash in PO loader's push method
  • Add guards to skip sections with empty/missing translations inside currentSections.find() callback, matching the existing guard pattern in the outer .map()

Test plan

  • Verify PO files with obsolete-only sections no longer crash during push
  • Verify normal PO file processing is unaffected

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a crash in the PO loader when processing sections without translations.

When a .po file section contains only obsolete entries or no
translations, Object.keys() on undefined csEntries throws a TypeError.
Add guards to skip sections with empty translations in the
currentSections.find() callback, matching the existing pattern used
in the outer map.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 20, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

A changeset file documents a patch-level fix for a crash in the PO loader. The actual fix adds validation guards to skip sections with no translations or missing translation entries during data push alignment, preventing the crash condition.

Changes

Cohort / File(s) Summary
Changeset Documentation
.changeset/fix-po-loader-crash.md
Adds a patch-level semantic version entry documenting the PO loader crash fix.
PO Loader Guards
packages/cli/src/cli/loaders/po/index.ts
Adds validation guards when locating the current section to skip sections with no translations or missing translation entries.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • AndreyHirsa

Poem

🐰 A crash in sections, now patched with care,
Guards keep empty translations from snare,
The PO loader bounces, no longer in pain,
Just skipping the void, then onward again! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description covers the bug fix and solution but deviates from the template by omitting the structured Changes section and providing incomplete Testing section with vague test descriptions rather than specific test case details. Follow the template structure: add a clear Changes section with bullet points, and expand Testing with specific test case descriptions or indicate tests were added to the codebase.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(cli): guard against empty translations in PO loader' directly and specifically describes the main change—adding guards to handle empty translations in the PO loader.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/po-loader-empty-translations-crash

Comment @coderabbitai help to get the list of available commands and usage tips.

@cherkanovart cherkanovart merged commit 56d0a47 into main Feb 20, 2026
10 checks passed
@cherkanovart cherkanovart deleted the fix/po-loader-empty-translations-crash branch February 20, 2026 20:25
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