Pick up files added to the Blog folder in Drive, and name nginx errors

Opening Tools → Media → Files (or a Choose a file picker) now looks in
the shared drive's Blog folder, at most every 30 seconds, and adds
anything put there in Drive itself: shared as anyone with the link,
previewed, Google Docs, Sheets and Slides included, folders and
shortcuts left out. A file Drive won't share is named in a note and
tried again every ten minutes.

A reply that isn't the API's (nginx's own error page) now says what it
was: a 413 names nginx's upload limit, a 502 the service, a 504 the
timeout, instead of "Server did not return JSON".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-29 19:14:40 -05:00
parent 5f13273e69
commit 6191322fea
6 changed files with 143 additions and 25 deletions

View file

@ -29,6 +29,13 @@ export class ApiError extends Error {
}
}
/* nginx's answers of its own, in words that point at the fix. */
const NOT_THE_API: Record<number, string> = {
413: "Too large for the web server: nginx's upload limit for this address is lower than the file (HTTP 413). The nginx block for it is in the docs.",
502: "The API isn't answering (HTTP 502). Check that the ngu-api service is running.",
504: "The API took too long to answer (HTTP 504). Try again; if it keeps happening, nginx's timeout for this address is too short.",
};
async function request(path, options: RequestInit = {}) {
const response = await fetch(`${BASE}${path}`, {
...options,
@ -39,9 +46,11 @@ async function request(path, options: RequestInit = {}) {
const type = response.headers.get("content-type") ?? "";
if (!type.includes("application/json")) {
// Usually the SPA fallback returning index.html for a URL the
// API doesn't serve. Parsing it would throw something useless.
throw new ApiError("Server did not return JSON.", {
// Not the API's answer: the SPA fallback returning index.html for
// a URL the API doesn't serve, or nginx's own error page when the
// request never reached the API (nothing in its journal then).
// Parsing it would throw something useless; say what it was.
throw new ApiError(NOT_THE_API[response.status] ?? `The server didn't answer as expected (HTTP ${response.status}).`, {
status: response.status,
});
}