Skip to content

fix(coder-routes): fix router collisions with web_extra_exposed_ports - #190

Merged
rfay merged 1 commit into
mainfrom
20260728_rfay_fix_coder_routes_slug_priority
Jul 28, 2026
Merged

fix(coder-routes): fix router collisions with web_extra_exposed_ports#190
rfay merged 1 commit into
mainfrom
20260728_rfay_fix_coder_routes_slug_priority

Conversation

@rfay

@rfay rfay commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary

  • coder-routes derived the Coder slug for any Traefik router whose service was named {project}-web-{port} (except port 8025) as the primary site, with no check on which port. A project using web_extra_exposed_ports (e.g. an Astro/Vite dev server on a second port) gets a second web-named service ({project}-web-4321), which computed the same slug/router name as the real primary site ({project}-web-80). Whichever was processed last silently clobbered the other's router in the merged YAML map, breaking the main site's coder_app URL and misrouting the extra port under the wrong Host() rule instead of the port-forwarding PathPrefix rule.
  • The dynamic add-on branch (used for ports with no dedicated coder_app, reached via Coder's dashboard port-forwarding URLs) set PathPrefix(/) at priority: 1. Every workspace's built-in catch-all fallback router (ddev-router-fallback-http/-https, baked into default_config.yaml) uses the identical rule at the identical priority, and the tie resolves in the fallback's favor — so these routers never actually received traffic, silently swallowed by DDEV's generic "no route found" page.

Fix

  1. Restrict the primary-site slug match to container port 80 specifically, so any other web-named port falls through to the dynamic add-on branch instead of colliding with the primary site.
  2. Bump the dynamic add-on router's priority from 1 to 10 so it beats the built-in fallback router.

Reproduced and verified against a live workspace (ddev.com project with web_extra_exposed_ports/web_extra_daemons for an Astro dev server on port 4321/4322): before the fix, both the main site's coder URL and the port-forward URL for 4322 returned 404; after the fix, both return 200, confirmed via direct curl against each Traefik entrypoint with the exact Host headers Coder sends.

Test plan

  • terraform fmt -recursive / terraform validate (no .tf changes in this PR, script-only)
  • Manually verified against a live freeform-template workspace running a project with web_extra_exposed_ports configured — main site, mailpit, and the extra-port dashboard-forward URL all route correctly after regenerating routes with the fixed script
  • CI integration test (.github/workflows/integration-test.yml) exercises coder-routes against a real workspace

🤖 Generated with Claude Code

https://claude.ai/code/session_018ZFiSd6KTRmRNFzAhpL1eE

Two bugs in the Traefik route generation broke any project using
web_extra_exposed_ports (e.g. an Astro/Vite dev server on a second port):

1. Slug derivation matched any router whose service was named
   "{project}-web-{port}" (excluding 8025) as the primary site, with no
   check on which port. A second web-based port (e.g. web-4321) computed
   the same slug/router name as the real primary site (web-80), so
   whichever was processed last silently clobbered the other's router in
   the merged YAML map — breaking the main site's coder_app URL and
   misrouting the extra port under the wrong Host-based rule. Restrict
   the primary-site match to container port 80 specifically.

2. The dynamic add-on branch (for ports with no dedicated coder_app,
   reached via Coder's dashboard port-forwarding URLs) used
   PathPrefix(`/`) at priority 1. Every workspace's built-in catch-all
   fallback router (ddev-router-fallback-http/-https) uses the identical
   rule at the identical priority, and the tie resolves in the
   fallback's favor — so these routers never actually received traffic,
   silently swallowed by DDEV's generic "no route found" page. Bump to
   priority 10 so it beats the fallback.

🤖 Developed with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-28 01:45 UTC

@rfay
rfay merged commit f719dc9 into main Jul 28, 2026
19 of 20 checks passed
@rfay
rfay deleted the 20260728_rfay_fix_coder_routes_slug_priority branch July 28, 2026 01:44
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