Repository navigation
feat(stack): serve auth email templates from content_path (CLI-2583, CLI-2746) - #7527
Conversation
CLI benchmark (Lightweight Commands): no changes foundCommit
API calls: unchanged for all 7 commands. Binary size: 134.8 MB, up 20.0 KB from 134.7 MB. Details: timing ranges, API calls per command, slowest phasesTiming ranges
API calls per command
Slowest phasesNo command moved beyond noise, so there are no phase deltas. Comment Previous runs
|
…lates-from-content_path
Coly010
left a comment
There was a problem hiding this comment.
Approving so you're unblocked, but there's one thing I'd like to see checked before this lands for Windows users.
-
FileSystem.ts:143,155- the Windows read opens withFILE_FLAG_OPEN_REPARSE_POINTand refuses anything withFILE_ATTRIBUTE_REPARSE_POINTset. I think that catches more than links: OneDrive placeholders and dedup files carry that attribute too. If a project lives in a OneDrive-synced folder (Documents/Desktop are often redirected there),stack startwould pass the start check, then every/email/<id>fetch would 404 and Auth would quietly send its built-in template. The only hint is the "Not a regular file at this path" warning from the owner.I haven't confirmed this on a real placeholder, so it may well not bite, and it needs someone with a Windows box to check. As far as I can tell the
GetFinalPathNameByHandleW === resolvedcomparison already catches a swapped link or junction, so the no-follow flag and the attribute refusal might not be adding containment. Opening normally, or only refusing name-surrogate tags, would avoid the false refusal. Unless I'm missing something about why it's needed?
Smaller, all happy to be told no:
FileSystem.ts:237and:162-163- no size cap on the read. A misconfiguredcontent_pathpointing at a big in-root file (a dump, a build artifact) gets loaded whole on every Auth fetch. Something like 1 MiB, refused afterstat, would cover it on both POSIX and Windows.FileSystem.ts:150,153,226- on Windows aCreateFileWfailure (sharing violation from an editor, access denied, path overMAX_PATH) all surfaces as "Not a regular file", which points people at the wrong cause. Carrying the Win32 error code for those would help.FileSystem.ts:234- the macOS check works because Bun resolvesrealpath("/dev/fd/N")to the real path (Node doesn't). It fails closed, so no security impact, but a one-line comment saying it depends on that would save someone a confusing 404 later.
Otherwise this looks good to me!
TL;DR
stack startnow serves auth email templates fromcontent_pathinstead of refusing themwhats introduced?
the api listener serves each configured template at
/email/<id>?token=<uuid>, and auth fetches it from the runtime url it already callsthe file is read on every fetch, so edits and atomic replacements show up without a restart
reads stay inside the project root like legacy, and the open file is checked against its resolved path, so a swapped link or folder is refused
why/how?
the stack refused every
content_pathtemplate, so projects with a custom invite or magic link email could not start on itflowchart LR A[auth] -- GET /email/invite with token --> L{{api listener}} L -- regular file inside the project --> T[supabase/templates/invite.html] L -. anything else .-> X[404]ref: