You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "thunguo (via GitHub)" <gi...@apache.org> on 2026/04/05 17:11:07 UTC

[PR] fix: issue translate robot [incubator-seata-go]

thunguo opened a new pull request, #1102:
URL: https://github.com/apache/incubator-seata-go/pull/1102

   <!--  Thanks for sending a pull request!
   -->
   <!-- Please make sure you have read and understood the contributing guidelines -->
   
   - [ ] I have registered the PR [changes](https://github.com/apache/incubator-seata-go/tree/master/changes).
   
   **What this PR does**:
   Fix issue translate robot
   
   **Which issue(s) this PR fixes**:
   
   <!--
   *Automatically closes linked issue when PR is merged.
   Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
   _If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
   -->
   
   Fixes #
   
   **Special notes for your reviewer**:
   
   **Does this PR introduce a user-facing change?**:
   
   <!--
   If no, just write "NONE" in the release-note block below.
   If yes, a release note is required:
   Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
   -->
   
   ```release-note
   NONE
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] fix: issue translate robot [incubator-seata-go]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #1102:
URL: https://github.com/apache/incubator-seata-go/pull/1102#discussion_r3037112337


##########
.github/workflows/issue-robot.yml:
##########
@@ -22,12 +22,94 @@ on:
   issues:
     types: [opened]
 
+permissions:
+  issues: write
+
 jobs:
-  build:
+  translate:
     runs-on: ubuntu-latest
     steps:
-      - uses: tomsun28/issues-translate-action@v2.6
+      - uses: actions/github-script@v7
         with:
-          # it is not necessary to decide whether you need to modify the issue header content
-          IS_MODIFY_TITLE: false
-          CUSTOM_BOT_NOTE: RoBot detected the issue body's language is not English, translate it automatically. πŸ‘―πŸ‘­πŸ»πŸ§‘β€πŸ€β€πŸ§‘πŸ‘«πŸ§‘πŸΏβ€πŸ€β€πŸ§‘πŸ»πŸ‘©πŸΎβ€πŸ€β€πŸ‘¨πŸΏπŸ‘¬πŸΏ
+          script: |
+            const isComment = context.eventName === 'issue_comment';
+            const text = isComment
+              ? context.payload.comment.body
+              : context.payload.issue.body;
+
+            if (!text || !text.trim()) return;
+
+            // Skip bot users and our own translation comments
+            const actor = isComment ? context.payload.comment.user : context.payload.issue.user;
+            if (actor.type === 'Bot') return;
+            if (text.startsWith('> Bot detected the issue body')) return;
+
+            // Quick heuristic: low non-ASCII ratio means likely English
+            const nonAscii = (text.match(/[^\x00-\x7F]/g) || []).length;
+            if (nonAscii / text.length < 0.1) return;
+
+            // Detect source language from Unicode character ranges
+            const cjk = (text.match(/[\u4e00-\u9fff]/g) || []).length;
+            const kana = (text.match(/[\u3040-\u30ff]/g) || []).length;
+            const hangul = (text.match(/[\uac00-\ud7af]/g) || []).length;
+            const cyrillic = (text.match(/[\u0400-\u04ff]/g) || []).length;
+
+            let srcLang = 'zh-CN';
+            if (kana > cjk * 0.1) srcLang = 'ja';
+            else if (hangul > cjk) srcLang = 'ko';
+            else if (cyrillic > cjk) srcLang = 'ru';
+

Review Comment:
   `srcLang` defaults to `zh-CN` unless the text matches a few specific Unicode ranges. For many non-English languages that aren’t CJK/Kana/Hangul/Cyrillic (e.g., Spanish with accents, Arabic, Hindi), this will pick the wrong source language and produce incorrect translations. Consider adding broader detection (or using an API mode that supports auto-detect) and only defaulting to zh-CN when there’s clear evidence of Chinese text.
   ```suggestion
               // Detect source language from Unicode character ranges.
               // Only use zh-CN when there is clear evidence of Han text;
               // otherwise prefer a script-specific language or skip translation.
               const cjk = (text.match(/[\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff]/g) || []).length;
               const kana = (text.match(/[\u3040-\u30ff]/g) || []).length;
               const hangul = (text.match(/[\uac00-\ud7af]/g) || []).length;
               const cyrillic = (text.match(/[\u0400-\u04ff]/g) || []).length;
               const arabic = (text.match(/[\u0600-\u06ff\u0750-\u077f\u08a0-\u08ff]/g) || []).length;
               const devanagari = (text.match(/[\u0900-\u097f]/g) || []).length;
               const hebrew = (text.match(/[\u0590-\u05ff]/g) || []).length;
               const greek = (text.match(/[\u0370-\u03ff]/g) || []).length;
               const thai = (text.match(/[\u0e00-\u0e7f]/g) || []).length;
   
               let srcLang = null;
               if (kana > cjk * 0.1) srcLang = 'ja';
               else if (hangul > cjk) srcLang = 'ko';
               else if (cyrillic > 0) srcLang = 'ru';
               else if (arabic > 0) srcLang = 'ar';
               else if (devanagari > 0) srcLang = 'hi';
               else if (hebrew > 0) srcLang = 'he';
               else if (greek > 0) srcLang = 'el';
               else if (thai > 0) srcLang = 'th';
               else if (cjk > 0) srcLang = 'zh-CN';
   
               if (!srcLang) {
                 core.info('Skipping translation: unable to determine a supported non-English source language.');
                 return;
               }
   ```



##########
.github/workflows/issue-robot.yml:
##########
@@ -22,12 +22,94 @@ on:
   issues:
     types: [opened]
 
+permissions:
+  issues: write
+
 jobs:
-  build:
+  translate:
     runs-on: ubuntu-latest
     steps:
-      - uses: tomsun28/issues-translate-action@v2.6
+      - uses: actions/github-script@v7
         with:

Review Comment:
   This workflow will still run for bot-authored comments (including the bot’s own translation comment) and only exits inside the script, which still consumes an Actions run. Consider adding a job- or step-level condition (e.g., `if: github.actor != 'github-actions[bot]'` and/or checking for `Bot` actors) to avoid starting the job for bot events at all.



##########
.github/workflows/issue-robot.yml:
##########
@@ -22,12 +22,94 @@ on:
   issues:
     types: [opened]
 
+permissions:
+  issues: write
+
 jobs:
-  build:
+  translate:
     runs-on: ubuntu-latest
     steps:
-      - uses: tomsun28/issues-translate-action@v2.6
+      - uses: actions/github-script@v7
         with:
-          # it is not necessary to decide whether you need to modify the issue header content
-          IS_MODIFY_TITLE: false
-          CUSTOM_BOT_NOTE: RoBot detected the issue body's language is not English, translate it automatically. πŸ‘―πŸ‘­πŸ»πŸ§‘β€πŸ€β€πŸ§‘πŸ‘«πŸ§‘πŸΏβ€πŸ€β€πŸ§‘πŸ»πŸ‘©πŸΎβ€πŸ€β€πŸ‘¨πŸΏπŸ‘¬πŸΏ
+          script: |
+            const isComment = context.eventName === 'issue_comment';
+            const text = isComment
+              ? context.payload.comment.body
+              : context.payload.issue.body;
+
+            if (!text || !text.trim()) return;
+
+            // Skip bot users and our own translation comments
+            const actor = isComment ? context.payload.comment.user : context.payload.issue.user;
+            if (actor.type === 'Bot') return;
+            if (text.startsWith('> Bot detected the issue body')) return;
+
+            // Quick heuristic: low non-ASCII ratio means likely English
+            const nonAscii = (text.match(/[^\x00-\x7F]/g) || []).length;
+            if (nonAscii / text.length < 0.1) return;
+
+            // Detect source language from Unicode character ranges
+            const cjk = (text.match(/[\u4e00-\u9fff]/g) || []).length;
+            const kana = (text.match(/[\u3040-\u30ff]/g) || []).length;
+            const hangul = (text.match(/[\uac00-\ud7af]/g) || []).length;
+            const cyrillic = (text.match(/[\u0400-\u04ff]/g) || []).length;
+
+            let srcLang = 'zh-CN';
+            if (kana > cjk * 0.1) srcLang = 'ja';
+            else if (hangul > cjk) srcLang = 'ko';
+            else if (cyrillic > cjk) srcLang = 'ru';
+
+            // Split text into chunks (MyMemory limit: 500 chars/request)
+            const input = text.substring(0, 3000);
+            const chunks = [];
+            let remaining = input;
+            while (remaining.length > 0) {
+              if (remaining.length <= 500) {
+                chunks.push(remaining);
+                break;
+              }
+              let i = remaining.lastIndexOf('\n', 500);
+              if (i < 150) i = remaining.lastIndexOf('。', 500);
+              if (i < 150) i = remaining.lastIndexOf('. ', 500);
+              if (i < 0 || i < 150) i = 500;
+              else i++;
+              chunks.push(remaining.substring(0, i));
+              remaining = remaining.substring(i);
+            }
+
+            // Translate each chunk via MyMemory API (free, no key needed)
+            const translated = [];
+            for (const chunk of chunks) {
+              const params = new URLSearchParams({
+                q: chunk,
+                langpair: `${srcLang}|en`,
+              });
+              const res = await fetch('https://api.mymemory.translated.net/get', {
+                method: 'POST',
+                headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
+                body: params.toString(),
+              });

Review Comment:
   The workflow sends the full issue/comment text to a third-party service (api.mymemory.translated.net) for translation. This can unintentionally exfiltrate sensitive information that users sometimes paste into issues (tokens, logs with secrets, emails). Consider gating translation behind an opt-in label/command, redacting common secret patterns before sending, and/or switching to an approved translation backend that keeps data within your control.



##########
.github/workflows/issue-robot.yml:
##########
@@ -22,12 +22,94 @@ on:
   issues:
     types: [opened]
 
+permissions:
+  issues: write
+
 jobs:
-  build:
+  translate:
     runs-on: ubuntu-latest
     steps:
-      - uses: tomsun28/issues-translate-action@v2.6
+      - uses: actions/github-script@v7
         with:
-          # it is not necessary to decide whether you need to modify the issue header content
-          IS_MODIFY_TITLE: false
-          CUSTOM_BOT_NOTE: RoBot detected the issue body's language is not English, translate it automatically. πŸ‘―πŸ‘­πŸ»πŸ§‘β€πŸ€β€πŸ§‘πŸ‘«πŸ§‘πŸΏβ€πŸ€β€πŸ§‘πŸ»πŸ‘©πŸΎβ€πŸ€β€πŸ‘¨πŸΏπŸ‘¬πŸΏ
+          script: |
+            const isComment = context.eventName === 'issue_comment';
+            const text = isComment
+              ? context.payload.comment.body
+              : context.payload.issue.body;
+
+            if (!text || !text.trim()) return;
+
+            // Skip bot users and our own translation comments
+            const actor = isComment ? context.payload.comment.user : context.payload.issue.user;
+            if (actor.type === 'Bot') return;
+            if (text.startsWith('> Bot detected the issue body')) return;
+
+            // Quick heuristic: low non-ASCII ratio means likely English
+            const nonAscii = (text.match(/[^\x00-\x7F]/g) || []).length;
+            if (nonAscii / text.length < 0.1) return;
+
+            // Detect source language from Unicode character ranges
+            const cjk = (text.match(/[\u4e00-\u9fff]/g) || []).length;
+            const kana = (text.match(/[\u3040-\u30ff]/g) || []).length;
+            const hangul = (text.match(/[\uac00-\ud7af]/g) || []).length;
+            const cyrillic = (text.match(/[\u0400-\u04ff]/g) || []).length;
+

Review Comment:
   The non-ASCII heuristic counts emoji and other symbols as non-ASCII. An otherwise-English issue/comment with a moderate number of emoji or non-ASCII punctuation can exceed the 0.1 threshold and trigger an unnecessary translation comment. Consider excluding common emoji ranges / variation selectors from the count, or using a more robust language detection approach.
   ```suggestion
               // Quick heuristic: count only language-bearing non-English scripts,
               // not emoji, variation selectors, or other non-ASCII symbols.
               const cjkRegex = /[\u4e00-\u9fff]/g;
               const kanaRegex = /[\u3040-\u30ff]/g;
               const hangulRegex = /[\uac00-\ud7af]/g;
               const cyrillicRegex = /[\u0400-\u04ff]/g;
   
               const cjk = (text.match(cjkRegex) || []).length;
               const kana = (text.match(kanaRegex) || []).length;
               const hangul = (text.match(hangulRegex) || []).length;
               const cyrillic = (text.match(cyrillicRegex) || []).length;
               const meaningfulNonEnglish = cjk + kana + hangul + cyrillic;
               if (meaningfulNonEnglish / text.length < 0.1) return;
   
               // Detect source language from Unicode character ranges
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] fix: issue translate robot [incubator-seata-go]

Posted by "Ethan-Xingyue (via GitHub)" <gi...@apache.org>.
Ethan-Xingyue merged PR #1102:
URL: https://github.com/apache/incubator-seata-go/pull/1102


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] fix: issue translate robot [incubator-seata-go]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #1102:
URL: https://github.com/apache/incubator-seata-go/pull/1102#issuecomment-4189217718

   ## [Codecov](https://app.codecov.io/gh/apache/incubator-seata-go/pull/1102?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 57.13%. Comparing base ([`e085c9b`](https://app.codecov.io/gh/apache/incubator-seata-go/commit/e085c9b1292ef4b81c08c0fea6aae7588df53e20?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`56d36cc`](https://app.codecov.io/gh/apache/incubator-seata-go/commit/56d36cc11d9e707c9b32ccdd1912d833b97da763?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #1102      +/-   ##
   ==========================================
   + Coverage   57.12%   57.13%   +0.01%     
   ==========================================
     Files         266      266              
     Lines       17488    17488              
   ==========================================
   + Hits         9990     9992       +2     
   + Misses       6677     6676       -1     
   + Partials      821      820       -1     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/incubator-seata-go/pull/1102?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org