fix(translate): 翻訳拡張を Smalruby CORS プロキシ経由に (#857)#858
Merged
Conversation
Scratch's translate service (translate-service.scratch.mit.edu) is CORS-locked to scratch.mit.edu, so smalruby.app is blocked with an Access-Control-Allow-Origin mismatch. Override serverURL to the Smalruby proxy (api.smalruby.app/scratch-api-proxy/) which forwards server-side and returns permissive CORS headers. Root cause: the override existed (74fb4c1) but had no Smalruby marker, so it was silently reverted by the v13.7.2 upstream merge (4e2ddc1, PR #630). It is the only unmarked Smalruby service-URL override in scratch-vm, so no other VM sites are affected. Wrap in Smalruby markers + add a guard test + record in smalruby-markers-vm.md so future upstream merges detect it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
🤖 autopilot status
Linked issue #857. Maintained by autopilot (single writer); do not edit. |
|
🚀 Preview deployed: https://smalruby.jp/smalruby3-editor/topic/autopilot-857/ |
The readme quoted the marker as '=== Smalruby: translate CORS proxy ===' but the code uses the required Start of/End of form. Align the doc so a future maintainer searching for the marker finds it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
🤖 autopilot 敵対的レビュー結果別レビュアー視点で差分を批判的に確認しました。重大な問題は無し。以下を確認済みです。 正確性
規約・再発防止
テスト・lint
自己修正(1 件)
スコープ確認
CORS の実挙動はコンテナ内 headless で確認できないため、PR 本文の 🙋 HITL 手順(本番/プレビューで翻訳ブロックが動くこと) の確認を人間にお願いします。 |
takaokouji
approved these changes
Jul 1, 2026
github-actions Bot
pushed a commit
that referenced
this pull request
Jul 1, 2026
…ot-857 fix(translate): 翻訳拡張を Smalruby CORS プロキシ経由に (#857)
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
翻訳拡張 (
scratch3_translate) が smalruby.app から実行すると CORS でブロックされる不具合を修正する。Scratch の翻訳サービス (translate-service.scratch.mit.edu) はAccess-Control-Allow-Originをscratch.mit.edu限定に締めたため、smalruby.app からの直叩きが失敗していた。VM 実装のserverURLを Smalruby の CORS 回避プロキシ (https://api.smalruby.app/scratch-api-proxy/) に上書きする。根本原因の調査(Issue コメントの依頼に対応)
74fb4c1f59(2026-01-20, "Restore Smalruby proxy URL for Translate extension")でserverURL = 'https://api.smalruby.app/scratch-api-proxy/'に上書きされていた。4e2ddc1406(upstream v13.7.2 マージ / PR feat: upstream merge 2026-05 (v13.7.2 — 284 commits, scratch-blocks v2) #630, 2026-05-03)でserverURLが upstream 値 (translate-service.scratch.mit.edu) に静かに revert された。マージ直前 (2026-03-08) までは Smalruby プロキシ値が残っていたことを確認済み。74fb4c1f59の上書きに Smalruby マーカーが無かったため、upstream マージのコンフリクト解決でも fix: re-align pre-spork-reverted files to upstream v13.7.2 (#749) #751-754 の post-merge 監査でも検知されず、素通りで revert された。api.smalruby.app/scratch-api-proxyの直書きは他に無し。mesh 系は別ディレクトリで Smalruby 固有ファイル)。したがってこのクラスの被害は translate のみで、他 VM 箇所への波及は無い。docs/maintenance/smalruby-markers-vm.mdに記録したため、次回以降の upstream マージでマーカーが差分検知の起点になる。Changes Made
packages/scratch-vm/src/extensions/scratch3_translate/index.js:serverURLを Smalruby プロキシに上書き(=== Smalruby: Start/End of translate CORS proxy ===マーカーで囲む)。リクエスト形?language=&text=はプロキシが透過するので変更不要。packages/scratch-vm/test/unit/extension_translate_proxy.js:getTranslateが Smalruby プロキシ URL を fetch することを保証するガードテスト(実 fetch 無し・スタブ)。packages/scratch-vm/.prettierignore: 新テストをホワイトリストに追加。docs/maintenance/smalruby-markers-vm.md: マーカーを記録。docs/extension-translate/README.md: upstream 区分を ⬆️ そのまま → 🔧 upstream 改良 に更新、プロキシ経由の説明を追記。Test Coverage
curl "https://api.smalruby.app/scratch-api-proxy/translate?language=en&text=%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF"→{"result":"Hi"}(HTTP 200) を確認。test/unit/extension_translate_proxy.jsを追加(RED→GREEN 確認済み)。packages/scratch-vmの lint pass(0 errors)。🙋 HITL: 実機での翻訳動作確認をお願いします
CORS の実挙動はコンテナ内 headless では確認できないため、本番またはプレビュー環境で以下の確認をお願いします:
translate-service.scratch.mit.edu ... CORS policyエラーが出ないこと)。api.smalruby.app/scratch-api-proxy/translateに向いていること。関連・留意
synthesis-service.scratch.mit.edu) も同じ CORS 構造で将来壊れる可能性があるが、synthesis 用プロキシが未整備のため 本 PR のスコープ外(別 Issue 要検討)。Related Issues
Closes #857