Files
atelier/sidecar/errors.ts
T
pastilhas f23ec1283b manifest, thin proxy router, and the sidecar backend
ported from the standalone officer-atelier service: providers (adapter-shaped, openai the only
adapter today), the generation queue, collections, and the database layer — kept on its own
Postgres database rather than folded into officer_db, since both collections and provider_settings
had rows on the machine this was extracted from.

what changed rather than just moved:
- images are served from an authenticated GET /files/:filename instead of an unauthenticated
  PUBLIC_URL-prefixed static route
- the OpenAI-key bootstrap fallback reads the secret store (getSecret) before .env, per-adapter
- provider_settings (the one-row-per-adapter shape providers replaced) did not come along — it has
  no callers left anywhere in the server code, only a migration script that also did not move

ping/echo (smoke-test routes with no caller) did not move either; the sidecar's own /_health covers
liveness.

not yet wired into the platform: sidecar/index.ts exists but nothing mounts it, and web/ has not
been written, so this is not yet a discoverable plugin.
2026-08-20 03:53:53 +00:00

15 lines
772 B
TypeScript

/**
* OpenAI's error envelope, shared by every route.
*
* In one place because it is a contract, not a convenience. A client written against their API reads
* `err.error.message`, so an error that answers with a bare string — as the framework's own notFound
* and onError handlers did until 2026-08-16 — does not merely return the wrong status: it breaks the
* parse. A caller checking `type` sees nothing at all.
*/
export const openaiError = (message: string, type: string, param?: string) => ({
error: { message, type, param: param ?? null, code: null },
});
/** Ids come back to us from our own responses; anything else never named a job that could exist. */
export const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;