Skip to content

fix: Handle HTTP 502 errors for large gist uploads#20

Merged
konard merged 4 commits intomainfrom
issue-19-d21156abf8ff
Jan 6, 2026
Merged

fix: Handle HTTP 502 errors for large gist uploads#20
konard merged 4 commits intomainfrom
issue-19-d21156abf8ff

Conversation

@konard
Copy link
Member

@konard konard commented Jan 6, 2026

Summary

Fixes #19 - Gist upload fails for ~50MB+ files with HTTP 502, but tool reports success.

Root Cause Analysis

While GitHub documents a 100MB limit for gist files, the REST API has practical limitations:

  • Large POST requests (>25-50MB) cause HTTP 502 errors due to server timeout/payload limits
  • The safe threshold matches the web interface limit of 25MB

Changes Made

1. Fix Success Detection Bug

  • Validate gist URL is present and valid before reporting success
  • Throw error with stderr details when gist creation fails

2. Lower Gist Threshold

  • Changed GITHUB_GIST_FILE_LIMIT from 100MB to 25MB
  • This matches the web interface limit and avoids HTTP 502 errors

3. Implement Automatic Fallback

  • When gist upload fails, automatically fall back to repository mode
  • Unless --only-gist is specified, in which case the error is thrown

4. Add Self-Test Feature

  • --test / -t: Run full self-test (1MB, 10MB, 24MB files)
  • --quick / -q: Run quick test (1MB file only)
  • Tests actual upload functionality on user's machine

5. Add Test Utilities

  • scripts/generate-test-file.mjs: Generate text files of specific sizes
  • Case study documentation in docs/case-studies/issue-19/

Test Results

File Size Expected Strategy Result
1 KB gist ✅ gist
1 MB gist ✅ gist
24 MB gist ✅ gist
26 MB repo ✅ repo

Usage Examples

# Normal upload - files ≤25MB go to gist, >25MB go to repo
gh-upload-log file.log

# Self-test to verify everything works
gh-upload-log --test

# Quick test (1MB only)
gh-upload-log --quick

# Force gist mode (will error if upload fails)
gh-upload-log large-file.log --only-gist

# Force repository mode
gh-upload-log file.log --only-repository

Breaking Changes

  • Files between 25-100MB will now use repository mode instead of gist mode
  • This is a fix, not a breaking change, as these files were failing with HTTP 502 before

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #19
@konard konard self-assigned this Jan 6, 2026
- Lower gist threshold from 100MB to 25MB (matching web interface limit)
- Add URL validation to detect failed gist creation
- Implement automatic fallback from gist to repository on failure
- Add --test/--quick CLI flags for self-testing functionality
- Add test file generator script and case study documentation
- Update unit tests for new behavior

Fixes #19

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard changed the title [WIP] Bug: Gist upload fails for ~50MB+ files with HTTP 502, but tool reports success fix: Handle HTTP 502 errors for large gist uploads Jan 6, 2026
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard marked this pull request as ready for review January 6, 2026 23:43
@konard
Copy link
Member Author

konard commented Jan 6, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $7.248191 USD
  • Calculated by Anthropic: $4.862610 USD
  • Difference: $-2.385581 (-32.91%)
    📎 Log file uploaded as GitHub Gist (857KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit 8c57ea7 into main Jan 6, 2026
8 checks passed
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.

Bug: Gist upload fails for ~50MB+ files with HTTP 502, but tool reports success

1 participant