Skip to content

fix(filebrowser): require agent_name when subdomain is false#877

Open
blinkagent[bot] wants to merge 1 commit intomainfrom
fix/filebrowser-agent-name-validation
Open

fix(filebrowser): require agent_name when subdomain is false#877
blinkagent[bot] wants to merge 1 commit intomainfrom
fix/filebrowser-agent-name-validation

Conversation

@blinkagent
Copy link
Copy Markdown
Contributor

@blinkagent blinkagent Bot commented Apr 29, 2026

Description

Fixes REG-4: the filebrowser module opens to a non-existent URL with the workspace path appended a second time when subdomain = false and agent_name is not provided, e.g.:

https://<coder-host>/@<owner>/<workspace>/apps/filebrowser/files/@<owner>/<workspace>.<agent>/apps/filebrowser/

Root cause

Coder's frontend always builds path-based app URLs as /@<owner>/<workspace>.<agent>/apps/<slug>/ (it always includes .<agent_name>, even for single-agent templates):

https://github.com/coder/coder/blob/main/site/src/modules/apps/apps.ts

return `${path}/@${workspace.owner_name}/${workspace.name}.${agent.name}/apps/${app.slug}/`;

The filebrowser module, however, only includes the agent segment in local.server_base_path (which becomes filebrowser's --baseURL) when the user explicitly passes agent_name. The variable description and the README both said agent_name was "only required if the template uses multiple agents", which is incorrect.

When the URLs disagree, filebrowser's reverse-proxy stripPrefix cannot strip the prefix, the path falls through filebrowser's /:catchAll(.*)* Vue route, and the router redirects to /files/${catchAll} — producing the duplicated path the user reported.

Fix

  • Add a lifecycle.precondition on coder_script.filebrowser that fails terraform apply with a clear, actionable error when subdomain = false and agent_name == null.
  • Update the agent_name variable description to state it is required whenever subdomain is false.
  • Update the README.md example for the path-based config to call out the requirement explicitly.
  • Bump the module version from 1.1.41.1.5.
  • Add a TS test covering the new precondition.

This avoids the silent misconfiguration that produces the duplicated URL, without breaking anyone whose existing template already sets agent_name (or uses subdomain = true).

Type of Change

  • New module
  • New template
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Module Information

Path: registry/coder/modules/filebrowser
New version: v1.1.5
Breaking change: [ ] Yes [x] No

Testing & Validation

  • bun test main.test.ts — 8 pass, 0 fail (includes new precondition test)
  • terraform fmt -recursive
  • terraform validate
  • bun x prettier --check
  • Manually verified the precondition fires with a minimal repro and passes when agent_name is supplied or subdomain = true.

Related Issues


Created on behalf of @matifali.

Generated with Blink.

Coder always builds path-based app URLs as /@<owner>/<workspace>.<agent>/apps/<slug>/, so the filebrowser baseURL must include the agent name to match the URL the user is actually browsing. When agent_name is omitted with subdomain=false, the baseURL is /@<owner>/<workspace>/apps/<slug> (no agent name), and filebrowser fails to strip the prefix from incoming requests. Its catch-all router then redirects to /files/<original-path>, producing duplicated paths like /@<owner>/<workspace>/apps/filebrowser/files/@<owner>/<workspace>.<agent>/apps/filebrowser/.

Add a lifecycle precondition that fails terraform apply with a clear error when subdomain=false and agent_name is not provided. Update the variable description and README accordingly, and bump the module to 1.1.5.
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