Skip to content

fix: fallback to direct README fetch when backend proxy fails#214

Merged
AmintaCCCP merged 1 commit into
mainfrom
fix/issue-200-readme-backend-fallback
Jun 8, 2026
Merged

fix: fallback to direct README fetch when backend proxy fails#214
AmintaCCCP merged 1 commit into
mainfrom
fix/issue-200-readme-backend-fallback

Conversation

@AmintaCCCP

@AmintaCCCP AmintaCCCP commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • add direct GitHub API fallback for README content when the backend proxy fails but a frontend token is available
  • add the same fallback for multilingual README variant discovery
  • cover backend-token failure, no-README, localized README, and variant-detection fallback behavior in ReadmeModal tests

Review / Audit Notes

  • Confirmed fallback does not run for normalized missing README responses (""), preserving the existing no-README UX.
  • Confirmed abort errors are not retried, avoiding stale modal updates.
  • Only src/components/ReadmeModal.tsx and src/components/ReadmeModal.test.tsx are included in the commit. Existing unrelated working-tree changes were left uncommitted.

Tests

  • npx eslint src/components/ReadmeModal.tsx src/components/ReadmeModal.test.tsx
  • npm test -- ReadmeModal --run
  • npm test -- --run

Note: full npm run lint currently fails on unrelated working-tree changes in ReleaseTimeline.tsx and useAppStore.ts; README files pass targeted lint.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved README loading reliability with fallback to direct GitHub API when the backend service is unavailable
  • Tests

    • Expanded test coverage for multilingual README loading and fallback scenarios

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: edbf7778-f91d-47f5-9a06-9704ba359cd6

📥 Commits

Reviewing files that changed from the base of the PR and between 1d7647b and b5641aa.

📒 Files selected for processing (2)
  • src/components/ReadmeModal.test.tsx
  • src/components/ReadmeModal.tsx

📝 Walkthrough

Walkthrough

ReadmeModal component refactoring centralizes README content and candidate fetching into reusable useCallback helpers with explicit backend-to-GitHub API fallback logic. New test mocking infrastructure and comprehensive fallback test cases verify that the component correctly retries GitHub API when backend proxy fails (if token exists) and respects explicit "missing README" responses.

Changes

README Loading with Backend/GitHub Fallback

Layer / File(s) Summary
Abort detection and unified fetch helpers
src/components/ReadmeModal.tsx
Added isAbortError helper to detect abort conditions and two new useCallback functions (fetchReadmeContentFromAvailableSource, fetchReadmeCandidatesFromAvailableSource) that implement backend-first-then-GitHub fallback logic with consistent abort propagation.
Hook consumer integration
src/components/ReadmeModal.tsx
Updated fetchReadmeContent and fetchReadmeVariants hooks to delegate to the new unified fetch helpers and adjusted their dependency lists to reference the new callbacks instead of direct dependencies.
Test mocking infrastructure
src/components/ReadmeModal.test.tsx
Added imports and vi.mock directives for GitHubApiService and useAppStore, established reusable mockGitHubApi object and setMockStore helper for configuring mocked service behavior and token state.
Test coverage for fallback behavior
src/components/ReadmeModal.test.tsx
Updated multilingual README setup to use direct GitHub API mocks and added multiple test cases verifying fallback rules: backend proxy errors trigger GitHub API fallback (when token exists), explicit "missing README" responses prevent fallback, and fallback handles both localized README path failures and candidate listing failures.

Sequence Diagram

sequenceDiagram
  participant Component as ReadmeModal
  participant FetchHelper as fetchReadmeContentFromAvailableSource
  participant Backend as backend adapter
  participant GitHub as GitHubApiService
  Component->>FetchHelper: fetch README
  FetchHelper->>Backend: try backend proxy
  Backend--XGitHub: on error
  FetchHelper->>GitHub: fallback to direct API
  GitHub->>FetchHelper: return content
  FetchHelper->>Component: content or abort
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • AmintaCCCP/GithubStarsManager#205: Refactors ReadmeModal README content and variant detection to use backend vs direct GitHubApiService fallback, directly overlapping with this PR's implementation of multilingual README switching and candidate detection in the same component area.

Poem

🐰 A helper hopped in, with abort in its hand,
To catch when our fetches fail—oh so grand!
Backend then GitHub, a fallback so clever,
Your README loads smoothly, now and forever! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: adding direct GitHub API fallback for README fetching when the backend proxy fails, which is the core focus of both modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-200-readme-backend-fallback

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@AmintaCCCP AmintaCCCP merged commit 714f1e6 into main Jun 8, 2026
19 of 28 checks passed
@AmintaCCCP AmintaCCCP deleted the fix/issue-200-readme-backend-fallback branch June 8, 2026 08:30
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.

1 participant