fix(site): handle invalid URLs in getAppHref to prevent UI crash by stirby · Pull Request #24691 · coder/coder · GitHub
Skip to content

fix(site): handle invalid URLs in getAppHref to prevent UI crash#24691

Open
stirby wants to merge 1 commit intomainfrom
fix/issue-24417
Open

fix(site): handle invalid URLs in getAppHref to prevent UI crash#24691
stirby wants to merge 1 commit intomainfrom
fix/issue-24417

Conversation

@stirby
Copy link
Copy Markdown
Collaborator

@stirby stirby commented Apr 23, 2026

Closes #24417

When a template specifies an invalid URL (e.g. a bare string like my-app with no scheme) on a coder_app resource with external = true, the call to new URL(app.url) in getAppHref() throws a TypeError, crashing the entire frontend UI.

Wraps the new URL() call in a try-catch and falls back to returning the raw URL when parsing fails. This ensures a single misconfigured coder_app never brings down the whole dashboard.

Changes:

  • site/src/modules/apps/apps.ts: try-catch around new URL(app.url) with raw-URL fallback
  • site/src/modules/apps/apps.test.ts: 3 new test cases (bare string, empty string, protocol-relative URL)

🤖 Generated by Coder Agents

Review notes
  • Production fix is a 9-line change; no behavioral change for valid URLs
  • All 1871 existing tests pass
  • Test covers the three invalid-URL variants mentioned in the issue

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.

fix: getAppHref crashes with invalid external app URL (no try-catch on new URL())

1 participant