Skip to content

fix(tts-audio): name the real cause of a rejected Admin key - #281

Merged
ngeorger merged 2 commits into
mainfrom
fix/tts-audio-invalid-jwt-message
Nov 27, 2026
Merged

ngeorger merged 2 commits into
mainfrom
fix/tts-audio-invalid-jwt-message

Conversation

@sredevopsorgagents

Copy link
Copy Markdown
Collaborator

The error is the Admin API key, not the code

The backfill died on its first request:

failed: Error: listing posts failed: Ghost 400 Bad Request

Ghost's response body said INVALID_JWT, but listPosts threw away the body and reported only statusText. That sent you looking at buckets and routing — the runbook's debugging section — when the answer was one line up.

Proof it is the key

Calling the live instance directly:

Case GET /ghost/api/admin/settings/
your key 6b093438… 400 INVALID_JWT
deliberately garbage key 400 INVALID_JWT
no Authorization header 403

Your key behaves identically to garbage: Ghost treats it as not a key. And the /site/ call I used earlier to say "the key works" was worthless — /site/ returns 200 with no auth at all. I should have tested an endpoint that requires an integration. That was my error, not a change on your side.

Fix on your side: Ghost Admin → Integrations → find/create tts-audio → make sure it has the Administrator role (needed to write codeinjection_foot) → copy its new Admin API key → make secret ADMIN_KEY='<id>:<secret>' … → make restart.

What this PR changes

  • backfill.mjs keeps Ghost's error code, names the failed key id, and says what to do.
  • ghost.mjs adds the same hint — a job's very first call is this request.
  • A listing failure is logged and ends with a structured {"result":"failed"} line instead of escaping as an uncaught exception.
  • README: how to tell a valid key from a revoked one, with both curls and the 403-vs-400 distinction.

Verified against the live endpoint with your key:

listing page 1 failed: listing posts failed: Ghost 400 INVALID_JWT — the Admin API key
was rejected (key id 6b093438902def00019b98fe). Check that the integration still exists
in Ghost Admin → Integrations, regenerate its Admin API key, and update the tts-audio Secret
{"result":"failed","scanned":0,...,"page":1}
exit code: 1

Gates

deploy/tts-audio/test.sh ✅ (70 worker tests, two new for the auth path) · yarn verify ✅

Reminder

This key, the webhook secret and the GCS service-account key have all been pasted into chat more than once. Rotate them.

SREDevOpsAgents added 2 commits November 27, 2026 06:54
The deployed cluster has no `sredevops-audio` bucket; the real one is
`tts-sredevopsorg` in project `sredevopsorg`. The service account has object
access to it (verified: list, upload, delete all succeed), so the ConfigMap was
the only thing wrong — but it was wrong in four places, and a job would have
synthesised for ~20 minutes and then failed on upload.

- base/configmap.yaml GCS_BUCKET, the Makefile's GCP_PROJECT/GCS_BUCKET
  defaults, and scripts/cors.sh
- README: document the defaults, note that gcp-bootstrap needs a principal that
  can administer the bucket (the runner SA deliberately cannot), and name the
  three ways a pipeline looks deployed but produces nothing audible — wrong
  bucket, objects not public, CORS not applied — with the two curl checks that
  catch them.

Verified end to end against the real bucket with the real model: the job
synthesised, encoded, uploaded gs://tts-sredevopsorg/audio/... and wrote the
marker, with contentType audio/mpeg and the immutable Cache-Control.
The backfill died with "listing posts failed: Ghost 400 Bad Request" while
Ghost's body said `INVALID_JWT` — the Admin API key is not valid on this
instance. The runbook's debugging section is about buckets and routing, so that
message sent the operator to the wrong place.

- backfill's listing now keeps Ghost's error code, names the failed key id, and
  says what to do (repair the integration, regenerate, update the Secret).
- the same hint is added to the shared client, since a job's very first call is
  this request.
- a listing failure is logged and ends the run as a structured `failed` line
  instead of escaping as an uncaught exception.
- README: how to tell a valid key from a revoked one. `/site/` answers 200
  *without auth*, so it proves nothing; compare a protected endpoint against a
  deliberately wrong key instead. 403 = no key, 400 INVALID_JWT = key rejected.

Verified against the live endpoint with the reported key: it now prints
"Ghost 400 INVALID_JWT — the Admin API key was rejected (key id 6b0934...)"
and exits 1 with a JSON line.
@ngeorger
ngeorger merged commit ed6506e into main Nov 27, 2026
6 checks passed
@ngeorger
ngeorger deleted the fix/tts-audio-invalid-jwt-message branch November 27, 2026 10:23
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.

2 participants