fix(config): unset TEMPLATES_PATH means embedded, not glob CWD - #150
Merged
Conversation
filepath.Join("", "*.html") globs the working directory, so a stray .html
anywhere markgo started became its template set. .env.example also shipped both
overlay paths pointed at the repo's own assets, costing 6x bytes per CSS/JS.
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.
Two coupled config defects, reported from
1mb-dev/logand reproduced here.filepath.Join("", "*.html")is"*.html", whichfilepath.Globresolves against the process working directory — so withTEMPLATES_PATHunset, any unrelated.htmlfile in whatever directory markgo started in was parsed as its template set, and boot failed with a set missing every name it needed. It presents as a recipe that worked for months breaking with no version or config change, as the directory collects files. Empty now short-circuits to embedded before any filesystem access. Of the two fixes the report offered, anchoring the glob to an absolute path only relocates the bug — an empty value still resolves against a directory nobody chose.The reason this was rarely hit is the second defect:
.env.exampleshippedTEMPLATES_PATH=./web/templates, masking it for anyone followingcp .env.example .env. It also shippedSTATIC_PATH=./web/static, pointing the overlay at a full copy of the embedded tree — every file shadowed, so every file loses its pre-compressed variants and build-version ETag. Measured onmain.css: 38,725 bytes and no validator, against 6,385 brotli with a 304-answering ETag. Both are documented as defaulting to empty; the example contradicted its own docs, and the docs understated what setting them costs.Also surfaces the wrapped cause on CLI errors —
Error: Failed to set up serverwith no mention of templates is what made this take a bisect to isolate. That goes to stderr with aCause:line; the v3.30.1 error-disclosure hardening is about HTTP response bodies read by strangers, not the operator's own terminal.