[Bug 35332] New: gulp po:update (may) generates incorrect Koha-messages.pot
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 Bug ID: 35332 Summary: gulp po:update (may) generates incorrect Koha-messages.pot Change sponsored?: --- Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: translate.koha-community.org Assignee: koha-bugs@lists.koha-community.org Reporter: jonathan.druart+koha@gmail.com QA Contact: testopia@bugs.koha-community.org Depends on: 35079
From bug 35079 comment 9, this is still valid.
[11:13:51] Error: Command failed: msgmerge --backup=off --no-wrap --quiet -F --update misc/translator/po/de-DE-messages.po misc/translator/Koha-messages.pot misc/translator/Koha-messages.pot:11:35: syntax error misc/translator/Koha-messages.pot:11: keyword "n" unknown misc/translator/Koha-messages.pot:12: end-of-line within string msgmerge: found 3 fatal errors at ChildProcess.exithandler (node:child_process:419:12) at ChildProcess.emit (node:events:513:28) at ChildProcess.emit (node:domain:552:15) at maybeClose (node:internal/child_process:1091:16) at Socket.<anonymous> (node:internal/child_process:449:11) at Socket.emit (node:events:513:28) at Socket.emit (node:domain:552:15) at Pipe.<anonymous> (node:net:321:12) at Pipe.callbackTrampoline (node:internal/async_hooks:130:17) [11:13:51] 'po:update' errored after 31 s It's really hard to debug as it happens randomly. It's either coming from the merge of the header or 2 processes writing into the same file at the same time The problem is always the same, the extract of the strings generates line 11 of Koha-messages.pot with an extra quote: "Content-Transfer-Encoding: 8bit"\n" instead of "Content-Transfer-Encoding: 8bit\n" And so the update of the .tt fail because msgmerge fail to read the .pot file. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35079 [Bug 35079] Add option to gulp tasks po:update and po:create to control if POT should be built -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=35103 --- Comment #1 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- A workaround is to call several times po:extract with --task (bug 35103). -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |julian.maurice@biblibre.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 Bug 35332 depends on bug 35079, which changed state. Bug 35079 Summary: Add option to gulp tasks po:update and po:create to control if POT should be built https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35079 What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to master |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=35342 -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 Paul Derscheid <paul.derscheid@lmscloud.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |paul.derscheid@lmscloud.de --- Comment #2 from Paul Derscheid <paul.derscheid@lmscloud.de> --- I have also run into this recently and found the issue: po_extract_messages merges the GNU xgettext (Perl) and xgettext-tt2 streams with gulp-concat-po, which takes the header from whichever stream arrives first. xgettext-tt2 writes Content-Transfer-Encoding as the last header line without a trailing \n, and pofile parses its value as '8bit"'. So Koha-messages.pot is corrupt whenever the TT2 stream wins, which is why it happens at random. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 Paul Derscheid <paul.derscheid@lmscloud.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |paul.derscheid@lmscloud.de |ity.org | Status|NEW |Needs Signoff -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 --- Comment #3 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Created attachment 211536 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211536&action=edit Bug 35332: Force Content-Transfer-Encoding in messages POT header - po_extract_messages merges the GNU xgettext (Perl) and xgettext-tt2 streams with gulp-concat-po, which takes the header from whichever stream arrives first - xgettext-tt2 writes Content-Transfer-Encoding as the last header line without a trailing \n, and pofile parses it as '8bit"' - When the TT2 stream wins, Koha-messages.pot gets "Content-Transfer-Encoding: 8bit"\n" and msgmerge fails with 'keyword "n" unknown' / 'end-of-line within string' - Set Content-Transfer-Encoding in the forced headers, as already done for Project-Id-Version and Content-Type Test plan: 1. In KTD, show how pofile handles the xgettext-tt2 header: cd /kohadevbox/koha perl misc/translator/xgettext-tt2 --from-code=UTF-8 -o /tmp/tt.pot koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc node -e 'const PO = require("pofile"); const po = PO.parse(require("fs").readFileSync("/tmp/tt.pot", "utf8")); require("fs").writeFileSync("/tmp/merged.pot", po.toString())' grep Content-Transfer /tmp/merged.pot msgcat /tmp/merged.pot -o /dev/null 2. The header line is "Content-Transfer-Encoding: 8bit"\n" and msgcat fails with 'keyword "n" unknown' 3. Apply the patch and run: gulp po:extract --task messages grep Content-Transfer misc/translator/Koha-messages.pot msgcat misc/translator/Koha-messages.pot -o /dev/null 4. The header line is "Content-Transfer-Encoding: 8bit\n" and msgcat succeeds 5. gulp po:update --lang de-DE completes without msgmerge errors Assisted-by: Opus 5.5 (Anthropic) Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211536|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 --- Comment #4 from David Nind <david@davidnind.com> --- Created attachment 211567 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211567&action=edit Bug 35332: Force Content-Transfer-Encoding in messages POT header - po_extract_messages merges the GNU xgettext (Perl) and xgettext-tt2 streams with gulp-concat-po, which takes the header from whichever stream arrives first - xgettext-tt2 writes Content-Transfer-Encoding as the last header line without a trailing \n, and pofile parses it as '8bit"' - When the TT2 stream wins, Koha-messages.pot gets "Content-Transfer-Encoding: 8bit"\n" and msgmerge fails with 'keyword "n" unknown' / 'end-of-line within string' - Set Content-Transfer-Encoding in the forced headers, as already done for Project-Id-Version and Content-Type Test plan: 1. In KTD, show how pofile handles the xgettext-tt2 header: cd /kohadevbox/koha perl misc/translator/xgettext-tt2 --from-code=UTF-8 -o /tmp/tt.pot koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc node -e 'const PO = require("pofile"); const po = PO.parse(require("fs").readFileSync("/tmp/tt.pot", "utf8")); require("fs").writeFileSync("/tmp/merged.pot", po.toString())' grep Content-Transfer /tmp/merged.pot msgcat /tmp/merged.pot -o /dev/null 2. The header line is "Content-Transfer-Encoding: 8bit"\n" and msgcat fails with 'keyword "n" unknown' 3. Apply the patch and run: gulp po:extract --task messages grep Content-Transfer misc/translator/Koha-messages.pot msgcat misc/translator/Koha-messages.pot -o /dev/null 4. The header line is "Content-Transfer-Encoding: 8bit\n" and msgcat succeeds 5. gulp po:update --lang de-DE completes without msgmerge errors Assisted-by: Opus 5.5 (Anthropic) Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |jonathan.druart@gmail.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211567|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 --- Comment #5 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 211597 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211597&action=edit Bug 35332: Force Content-Transfer-Encoding in messages POT header - po_extract_messages merges the GNU xgettext (Perl) and xgettext-tt2 streams with gulp-concat-po, which takes the header from whichever stream arrives first - xgettext-tt2 writes Content-Transfer-Encoding as the last header line without a trailing \n, and pofile parses it as '8bit"' - When the TT2 stream wins, Koha-messages.pot gets "Content-Transfer-Encoding: 8bit"\n" and msgmerge fails with 'keyword "n" unknown' / 'end-of-line within string' - Set Content-Transfer-Encoding in the forced headers, as already done for Project-Id-Version and Content-Type Test plan: 1. In KTD, show how pofile handles the xgettext-tt2 header: cd /kohadevbox/koha perl misc/translator/xgettext-tt2 --from-code=UTF-8 -o /tmp/tt.pot koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc node -e 'const PO = require("pofile"); const po = PO.parse(require("fs").readFileSync("/tmp/tt.pot", "utf8")); require("fs").writeFileSync("/tmp/merged.pot", po.toString())' grep Content-Transfer /tmp/merged.pot msgcat /tmp/merged.pot -o /dev/null 2. The header line is "Content-Transfer-Encoding: 8bit"\n" and msgcat fails with 'keyword "n" unknown' 3. Apply the patch and run: gulp po:extract --task messages grep Content-Transfer misc/translator/Koha-messages.pot msgcat misc/translator/Koha-messages.pot -o /dev/null 4. The header line is "Content-Transfer-Encoding: 8bit\n" and msgcat succeeds 5. gulp po:update --lang de-DE completes without msgmerge errors Assisted-by: Opus 5.5 (Anthropic) Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 --- Comment #6 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 211598 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211598&action=edit Bug 35332: Terminate the last POT header line in xgettext-tt2 Locale::XGettext joins the header fields with "\n" but does not terminate the last one, so xgettext-tt2 writes "Content-Transfer-Encoding: 8bit" instead of "Content-Transfer-Encoding: 8bit\n" pofile (used by gulp-concat-po) then parses the value as '8bit"' and writes a corrupted header, making msgmerge fail when the TT2 stream is the first to reach gulp-concat-po. The previous patch avoids the corruption by forcing Content-Transfer-Encoding in gulpfile.js. That works, but it fixes the symptom in the consumer rather than the malformed output of the producer: - It only works because the broken field happens to be one we can force. If Locale::XGettext adds or reorders header fields, whichever field ends up last gets corrupted and the random failure is back. - GNU xgettext terminates every header line with \n. xgettext-tt2 should produce the same output so that every tool reading it, not only gulp-concat-po with the right forced headers, gets a clean header. Fix the header at its source by overriding __poHeader in xgettext-tt2, and remove the Content-Transfer-Encoding workaround from gulpfile.js. Test plan: The failure only happens when xgettext-tt2 finishes before GNU xgettext. In KTD GNU xgettext is much faster (~0.5s vs ~3s), so the TT2 stream almost never wins. Slow GNU xgettext down by a random delay to trigger the race (/tmp is mounted noexec in KTD, use another dir): mkdir -p /opt/slow printf '#!/bin/bash\nsleep $((RANDOM %% 6))\nexec /usr/bin/xgettext "$@"\n' > /opt/slow/xgettext chmod +x /opt/slow/xgettext 1. Without the patches from this bug, run: for i in $(seq 1 20); do PATH=/opt/slow:$PATH gulp po:extract --task messages >/dev/null 2>&1 msgcat misc/translator/Koha-messages.pot -o /dev/null || { grep Content-Transfer misc/translator/Koha-messages.pot; break; } done 2. After a few iterations msgcat fails with: syntax error / keyword "n" unknown and the header line is: "Content-Transfer-Encoding: 8bit"\n" gulp po:update --lang de-DE then fails with the same msgmerge errors 3. Apply the patches and repeat 1 4. All the iterations pass, the header line is always "Content-Transfer-Encoding: 8bit\n" and gulp po:update --lang de-DE completes without msgmerge errors Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 Paul Derscheid <paul.derscheid@lmscloud.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 Paul Derscheid <paul.derscheid@lmscloud.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211597|0 |1 is obsolete| | Attachment #211598|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 --- Comment #7 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Created attachment 211613 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211613&action=edit Bug 35332: Force Content-Transfer-Encoding in messages POT header - po_extract_messages merges the GNU xgettext (Perl) and xgettext-tt2 streams with gulp-concat-po, which takes the header from whichever stream arrives first - xgettext-tt2 writes Content-Transfer-Encoding as the last header line without a trailing \n, and pofile parses it as '8bit"' - When the TT2 stream wins, Koha-messages.pot gets "Content-Transfer-Encoding: 8bit"\n" and msgmerge fails with 'keyword "n" unknown' / 'end-of-line within string' - Set Content-Transfer-Encoding in the forced headers, as already done for Project-Id-Version and Content-Type Test plan: 1. In KTD, show how pofile handles the xgettext-tt2 header: cd /kohadevbox/koha perl misc/translator/xgettext-tt2 --from-code=UTF-8 -o /tmp/tt.pot koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc node -e 'const PO = require("pofile"); const po = PO.parse(require("fs").readFileSync("/tmp/tt.pot", "utf8")); require("fs").writeFileSync("/tmp/merged.pot", po.toString())' grep Content-Transfer /tmp/merged.pot msgcat /tmp/merged.pot -o /dev/null 2. The header line is "Content-Transfer-Encoding: 8bit"\n" and msgcat fails with 'keyword "n" unknown' 3. Apply the patch and run: gulp po:extract --task messages grep Content-Transfer misc/translator/Koha-messages.pot msgcat misc/translator/Koha-messages.pot -o /dev/null 4. The header line is "Content-Transfer-Encoding: 8bit\n" and msgcat succeeds 5. gulp po:update --lang de-DE completes without msgmerge errors Assisted-by: Opus 5.5 (Anthropic) Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 --- Comment #8 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Created attachment 211614 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211614&action=edit Bug 35332: Terminate the last POT header line in xgettext-tt2 Locale::XGettext joins the header fields with "\n" but does not terminate the last one, so xgettext-tt2 writes "Content-Transfer-Encoding: 8bit" instead of "Content-Transfer-Encoding: 8bit\n" pofile (used by gulp-concat-po) then parses the value as '8bit"' and writes a corrupted header, making msgmerge fail when the TT2 stream is the first to reach gulp-concat-po. The previous patch avoids the corruption by forcing Content-Transfer-Encoding in gulpfile.js. That works, but it fixes the symptom in the consumer rather than the malformed output of the producer: - It only works because the broken field happens to be one we can force. If Locale::XGettext adds or reorders header fields, whichever field ends up last gets corrupted and the random failure is back. - GNU xgettext terminates every header line with \n. xgettext-tt2 should produce the same output so that every tool reading it, not only gulp-concat-po with the right forced headers, gets a clean header. Fix the header at its source by overriding __poHeader in xgettext-tt2, and remove the Content-Transfer-Encoding workaround from gulpfile.js. Test plan: The failure only happens when xgettext-tt2 finishes before GNU xgettext. In KTD GNU xgettext is much faster (~0.5s vs ~3s), so the TT2 stream almost never wins. Slow GNU xgettext down by a random delay to trigger the race (/tmp is mounted noexec in KTD, use another dir): mkdir -p /opt/slow printf '#!/bin/bash\nsleep $((RANDOM %% 6))\nexec /usr/bin/xgettext "$@"\n' > /opt/slow/xgettext chmod +x /opt/slow/xgettext 1. Without the patches from this bug, run: for i in $(seq 1 20); do PATH=/opt/slow:$PATH gulp po:extract --task messages >/dev/null 2>&1 msgcat misc/translator/Koha-messages.pot -o /dev/null || { grep Content-Transfer misc/translator/Koha-messages.pot; break; } done 2. After a few iterations msgcat fails with: syntax error / keyword "n" unknown and the header line is: "Content-Transfer-Encoding: 8bit"\n" gulp po:update --lang de-DE then fails with the same msgmerge errors 3. Apply the patches and repeat 1 4. All the iterations pass, the header line is always "Content-Transfer-Encoding: 8bit\n" and gulp po:update --lang de-DE completes without msgmerge errors Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35332 --- Comment #9 from Paul Derscheid <paul.derscheid@lmscloud.de> --- We do override Locale::XGettext internals here, but when I look at their release cadence it is unlikely to break in the coming years :D -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org