fix(gh-comment-attach-files): retry uploads and fix URL detection#457
Open
shunk031 wants to merge 4 commits into
Open
fix(gh-comment-attach-files): retry uploads and fix URL detection#457shunk031 wants to merge 4 commits into
shunk031 wants to merge 4 commits into
Conversation
- upload_files() に最大 3 回のリトライを追加。アップロードの クラッシュ・失敗・URL 未検出をそれぞれハンドリングし、 ブラウザの再起動も行う - URL 検出ロジックを修正: stagedName チェックは GitHub が挿入する "![Uploading stagedName…]()" プレースホルダーで誤検知するため、 URL ヒントの出現回数を数える方式に変更 - perform_upload() は即時 raise せず結果を返すように変更 (リトライはcallerのupload_files()が制御) - run_playwright_value() で "undefined" stdout と JSONDecodeError を適切にハンドリング - wait_for_comment_composer() のエラーメッセージを 1 行に統一 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #457 +/- ##
==========================================
- Coverage 88.93% 88.79% -0.15%
==========================================
Files 9 9
Lines 235 232 -3
==========================================
- Hits 209 206 -3
Misses 26 26
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…in and login detection
- Default to headless browser (removes always-on --headed flag)
- Add --headed CLI flag for cases where login is required
- Detect /login or /session redirect in wait_for_comment_composer and raise a clear error directing user to --headed
- Thread headed param through upload_files and open_browser call in retry path
- Move import sys to top-level (was inline in upload_files); clean up __import__("sys") hack
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…aded is set When running with --headed, the user may be in the middle of logging in. Skipping the login detection error in headed mode lets the polling continue until the user completes authentication and lands on the target page. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
perform_upload()to return results instead of raising immediatelyrun_playwright_value()--headedopt-in flagChanges
1. Retry logic (
upload_files)Handles upload failures in unstable environments (CI, slow networks, etc.).
Retries up to 3 times with appropriate recovery per failure type:
CalledProcessError(crash)upload_result.ok == false2. URL detection false-positive fix
Problem: GitHub inserts a temporary placeholder
![Uploading stagedName…]()into the textarea immediately after receiving a file. The old implementation matched onstagedNameand incorrectly treated this as a completed upload.Fix: Drop the
stagedNamecheck; instead compare the count of URL hint occurrences before and after the upload:3. Headless-by-default with
--headedopt-inPreviously the browser always launched in headed (visible) mode, which interrupted other work with unexpected windows.
--headed: opt-in flag for when a GitHub login is needed.wait_for_comment_composerdetects a/loginor/sessionredirect, it exits immediately with a clear message pointing the user to--headed.4. Other
perform_upload(): return result instead of raising; retry control consolidated in callerrun_playwright_value(): handle"undefined"stdout andJSONDecodeErrorwait_for_comment_composer(): unify error message to a single lineimport sysmoved to top-level; remove__import__("sys")workaround🤖 Generated with Claude Code