fix(filebrowser): require agent_name when subdomain is false#877
Open
blinkagent[bot] wants to merge 1 commit intomainfrom
Open
fix(filebrowser): require agent_name when subdomain is false#877blinkagent[bot] wants to merge 1 commit intomainfrom
blinkagent[bot] wants to merge 1 commit intomainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes REG-4: the
filebrowsermodule opens to a non-existent URL with the workspace path appended a second time whensubdomain = falseandagent_nameis not provided, e.g.: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
The filebrowser module, however, only includes the agent segment in
local.server_base_path(which becomes filebrowser's--baseURL) when the user explicitly passesagent_name. The variable description and the README both saidagent_namewas "only required if the template uses multiple agents", which is incorrect.When the URLs disagree, filebrowser's reverse-proxy
stripPrefixcannot 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
lifecycle.preconditiononcoder_script.filebrowserthat failsterraform applywith a clear, actionable error whensubdomain = falseandagent_name == null.agent_namevariable description to state it is required wheneversubdomainisfalse.README.mdexample for the path-based config to call out the requirement explicitly.1.1.4→1.1.5.This avoids the silent misconfiguration that produces the duplicated URL, without breaking anyone whose existing template already sets
agent_name(or usessubdomain = true).Type of Change
Module Information
Path:
registry/coder/modules/filebrowserNew version:
v1.1.5Breaking change: [ ] Yes [x] No
Testing & Validation
bun test main.test.ts— 8 pass, 0 fail (includes new precondition test)terraform fmt -recursiveterraform validatebun x prettier --checkagent_nameis supplied orsubdomain = true.Related Issues
Created on behalf of @matifali.
Generated with Blink.