Skip to content

fix: Avoid error when Raw button is absent on GitHub file pages - #169

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/missing-github-raw-button
Open

sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/missing-github-raw-button

Conversation

@sentry

@sentry sentry Bot commented Sep 25, 2026

Copy link
Copy Markdown

This PR addresses the "Error: Raw button not found" issue (BROWSER-EXTENSION-SJ) that occurred when the browser extension was active on GitHub file pages that do not display a 'Raw' button (e.g., binary files, images, LFS-tracked files).

Root Cause: The extension's logic assumed the presence of a [data-testid="raw-button"] element on all /blob/ URLs. However, GitHub only renders this button for plain-text files. When navigating to other file types, the document.querySelector call would return null, leading to an unhandled error.

Changes Made:

  1. src/content/github/file/main.tsx: Added an explicit check for the [data-testid="raw-button"] element within the main() function. If the button is not found, the extension now logs a message and returns early, preventing createCoverageButton() from being called and thus avoiding the error.
  2. src/content/github/file/utils/dropdown.tsx: Modified the createDropdown() function to return null instead of throwing an error if the [data-testid="raw-button"] is not found. This makes the function more robust and allows callers to handle its absence gracefully.
  3. src/content/github/file/main.tsx: Updated the call sites for createDropdown() to check for a null return value. If createDropdown() returns null, the subsequent logic for creating and attaching the dropdown (flags and components) is skipped, ensuring no further errors occur.

Fixes BROWSER-EXTENSION-SJ

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 248 bytes (0.04%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
codecov-browser-extension-array-push 660.71kB 248 bytes (0.04%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: codecov-browser-extension-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
background.js 89 bytes 207.75kB 0.04%
githubFile.js 159 bytes 11.62kB 1.39%

Files in githubFile.js:

  • ./src/content/github/file/main.tsx → Total Size: 12.11kB

  • ./src/content/github/file/utils/dropdown.tsx → Total Size: 1.91kB

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.

0 participants