claude-code - 💡(How to fix) Fix [Bug] Rails 8 allow_browser middleware blocks link preview bots with 406 response [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52703Fetched 2026-04-24 10:41:56
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3

Error Message

[{"error":"Error: Plugin MCP server error - mcp-config-invalid: MCP server github invalid: Missing environment variables: GITHUB_PERSONAL_ACCESS_TOKEN\n at TWH (/$bunfs/root/src/entrypoints/cli.js:2736:30496)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-24T04:05:34.047Z"},{"error":"Error: Plugin MCP server error - mcp-config-invalid: MCP server github invalid: Missing environment variables: GITHUB_PERSONAL_ACCESS_TOKEN\n at TWH (/$bunfs/root/src/entrypoints/cli.js:2736:30496)\n at async L (/$bunfs/root/src/entrypoints/cli.js:6300:11825)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-24T04:05:34.460Z"},{"error":"Error: Plugin MCP server error - mcp-config-invalid: MCP server github invalid: Missing environment variables: GITHUB_PERSONAL_ACCESS_TOKEN\n at TWH (/$bunfs/root/src/entrypoints/cli.js:2736:30496)\n at async R (/$bunfs/root/src/entrypoints/cli.js:6300:11019)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-04-24T04:05:34.462Z"}]

Code Example

[{"error":"Error: Plugin MCP server error - mcp-config-invalid: MCP server github invalid: Missing environment variables: GITHUB_PERSONAL_ACCESS_TOKEN\n    at TWH (/$bunfs/root/src/entrypoints/cli.js:2736:30496)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-24T04:05:34.047Z"},{"error":"Error: Plugin MCP server error - mcp-config-invalid: MCP server github invalid: Missing environment variables: GITHUB_PERSONAL_ACCESS_TOKEN\n    at TWH (/$bunfs/root/src/entrypoints/cli.js:2736:30496)\n    at async L (/$bunfs/root/src/entrypoints/cli.js:6300:11825)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-24T04:05:34.460Z"},{"error":"Error: Plugin MCP server error - mcp-config-invalid: MCP server github invalid: Missing environment variables: GITHUB_PERSONAL_ACCESS_TOKEN\n    at TWH (/$bunfs/root/src/entrypoints/cli.js:2736:30496)\n    at async R (/$bunfs/root/src/entrypoints/cli.js:6300:11019)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-24T04:05:34.462Z"}]
RAW_BUFFERClick to expand / collapse

Bug Description Claude assumed the following issue was a blocked IP issue from our Hetzner cloud; and kept cycling through solutions to resolve it when in fact it was: Here's what happened — the short version:

The symptom: iMessage (and other link-preview bots like Slack/Discord/WhatsApp) were getting no preview card when someone texted a dasha.fm URL. Your OG tags were in order — eccdc18 had even hardened them with og:image:secure_url, og:image:type, and og:locale. First instinct was that Hetzner or Cloudflare was blocking the preview fetchers by IP.

The actual cause: Rails 8 ships with allow_browser versions: :modern in ApplicationController. That middleware inspects the User-Agent and returns HTTP 406 Not Acceptable (rendering public/406-unsupported-browser.html) for anything it doesn't recognize as a modern browser — and the iMessage/Apple link preview fetcher's UA didn't qualify. So the fetcher got a 406 + a static HTML fallback page with no og:* tags, and iMessage had nothing to render.

Not an IP block at all. The server was happily answering — just with the wrong response body to anyone whose UA didn't look like a recent Chrome/Safari/Firefox.

The fix (commit 87e6445):

  • Removed allow_browser versions: :modern from app/controllers/application_controller.rb
  • Deleted public/406-unsupported-browser.html (the fallback template that had no OG tags)

After that, bots get a normal 200 with the full <head> including OG tags, and iMessage renders the preview card.

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.1.119
  • Feedback ID: 212e1787-80bf-4f58-b96f-1da7ed12b504

Errors

[{"error":"Error: Plugin MCP server error - mcp-config-invalid: MCP server github invalid: Missing environment variables: GITHUB_PERSONAL_ACCESS_TOKEN\n    at TWH (/$bunfs/root/src/entrypoints/cli.js:2736:30496)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-24T04:05:34.047Z"},{"error":"Error: Plugin MCP server error - mcp-config-invalid: MCP server github invalid: Missing environment variables: GITHUB_PERSONAL_ACCESS_TOKEN\n    at TWH (/$bunfs/root/src/entrypoints/cli.js:2736:30496)\n    at async L (/$bunfs/root/src/entrypoints/cli.js:6300:11825)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-24T04:05:34.460Z"},{"error":"Error: Plugin MCP server error - mcp-config-invalid: MCP server github invalid: Missing environment variables: GITHUB_PERSONAL_ACCESS_TOKEN\n    at TWH (/$bunfs/root/src/entrypoints/cli.js:2736:30496)\n    at async R (/$bunfs/root/src/entrypoints/cli.js:6300:11019)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-04-24T04:05:34.462Z"}]

extent analysis

TL;DR

Remove the allow_browser versions: :modern middleware from the ApplicationController to prevent it from returning a 406 error to unrecognized User-Agents.

Guidance

  • Identify if the allow_browser middleware is enabled in the ApplicationController and remove it if necessary.
  • Verify that the removal of the middleware resolves the issue by checking the response body for OG tags when accessing the URL with an unrecognized User-Agent.
  • Check for any other potential middleware or configuration that may be interfering with the response.
  • Consider adding custom logic to handle unrecognized User-Agents instead of removing the middleware entirely.

Example

No code example is provided as the fix is straightforward and only requires removing a line of code from the ApplicationController.

Notes

The provided error messages do not seem to be related to the issue described, as they mention missing environment variables and MCP server errors.

Recommendation

Apply the workaround by removing the allow_browser versions: :modern middleware, as it is the root cause of the issue and removing it has been confirmed to resolve the problem.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING