Skip to content

fix(config): unset TEMPLATES_PATH means embedded, not glob CWD - #150

Merged
vnykmshr merged 1 commit into
mainfrom
fix/templates-path-embedded-default
Aug 7, 2026
Merged

fix(config): unset TEMPLATES_PATH means embedded, not glob CWD#150
vnykmshr merged 1 commit into
mainfrom
fix/templates-path-embedded-default

Conversation

@vnykmshr

@vnykmshr vnykmshr commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Two coupled config defects, reported from 1mb-dev/log and reproduced here.

filepath.Join("", "*.html") is "*.html", which filepath.Glob resolves against the process working directory — so with TEMPLATES_PATH unset, any unrelated .html file 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.example shipped TEMPLATES_PATH=./web/templates, masking it for anyone following cp .env.example .env. It also shipped STATIC_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 on main.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 server with no mention of templates is what made this take a bisect to isolate. That goes to stderr with a Cause: line; the v3.30.1 error-disclosure hardening is about HTTP response bodies read by strangers, not the operator's own terminal.

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.
@vnykmshr
vnykmshr merged commit 21f01f1 into main Aug 7, 2026
8 checks passed
@vnykmshr
vnykmshr deleted the fix/templates-path-embedded-default branch August 7, 2026 10:50
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