|
|
@@ -112,6 +112,20 @@ meaning "no fallback - an unmatched path answers a plain 404", not an absent
|
|
|
key.** An absent key leaves the stored value alone; a present empty string is
|
|
|
stored.
|
|
|
|
|
|
+**THE FALLBACK DOES NOT DISTINGUISH A MISSING ROUTE FROM A MISSING FILE, so
|
|
|
+with an `index` set a missing image answers 200 and `text/html`.** The lookup
|
|
|
+is one path lookup against the stored `path` metadata, and ANY miss under the
|
|
|
+mount takes the fallback - there is no extension rule and no content-type rule,
|
|
|
+so `/img/avatar.webp` that was never uploaded returns your SPA shell with a 200
|
|
|
+exactly as `/settings` does. Two consequences, pulling in opposite directions.
|
|
|
+A caller cannot use **absence as a signal**: a 404 is not available for a
|
|
|
+missing asset while a fallback is configured, so a client that branches on one
|
|
|
+will branch on the HTML instead, and an `<img>` will render broken rather than
|
|
|
+report anything. Conversely **an unpublished file leaks nothing** - it is
|
|
|
+indistinguishable from a route, which is the same answer a stranger gets for
|
|
|
+any path at all. There is currently no way to have both an SPA fallback and a
|
|
|
+404 on a missing asset; `index: ""` buys the 404 and costs the SPA.
|
|
|
+
|
|
|
### The path a file is served at comes from its METADATA, not its name
|
|
|
|
|
|
File names are a single path segment, so `assets/index-a1b2.js` cannot be a
|
|
|
@@ -585,6 +599,8 @@ export default async function (ctx) {
|
|
|
|
|
|
**The return value shapes the response.** An object whose keys are a non-empty subset of `{status, headers, body}` is a response envelope; any other object is sent as a `200` body; an object MIXING envelope keys with other keys **fails the run** rather than being guessed at. Host calls are synchronous, so `await` is optional - it works because awaiting a non-promise is a no-op.
|
|
|
|
|
|
+**A FUNCTION CANNOT RETURN BINARY, AND THE ASYMMETRY WITH `ctx.fetch` IS EASY TO READ THE WRONG WAY ROUND.** `body` is a string or a JSON value, so a string is sent as-is and anything else is `dump()`ed as JSON. There is **no `bodyBase64` and no `bodyBytes` on the RETURN side** - those exist on `ctx.fetch`'s REQUEST side only, and `bodyBase64` in an envelope is not a binary escape hatch but an unknown key, which fails the run as a mixed envelope. A byte outside a valid UTF-8 sequence cannot survive a JSON string, which is the same constraint that makes `responseType: 'base64'` necessary inbound; outbound there is nothing to opt into. So `ctx.files.get()` handing you base64 means a function can READ a stored file and cannot EMIT it. **The practical consequence is that a function cannot gate a binary asset:** a session check in front of an image needs the function to serve the bytes, and the static mount that can serve them is unauthenticated by design. Today the only shapes available are publishing the file on the mount (public to anyone who learns the path - note the path is not guessable from the listing, which is authenticated) or returning a **302** to a URL you control. Tracked as SV-50; say so if you need it.
|
|
|
+
|
|
|
**The id lives in the source, not in the URL.** A script exports `export const on = { id: 'kb-search', type: 'http', route: '/kb/:topic', method: 'GET' }`, and that `id` is the registry row's identity. `path` records where the author keeps the file and carries no meaning, so moving `kb-search.js` to `lib/search.js` keeps the same row - and the policy an admin granted travels with it.
|
|
|
|
|
|
**Every write is compiled on a runner before it is stored.** The engine that validates is the engine that will execute. A compile failure is **422** `compile_failed` with the error; an `on` block with no id is **422** `missing_function_id`; no healthy runner is **503** `no_runner` and nothing is stored. Code is never stored unvalidated.
|