Skip to content

Sync with upstream Ghost v6.78.0 - #41

Merged
andreascreten merged 174 commits into
mainfrom
chore/sync-v6.78.0
Nov 18, 2026
Merged

andreascreten merged 174 commits into
mainfrom
chore/sync-v6.78.0

Conversation

@andreascreten

Copy link
Copy Markdown
Member

Syncing fork to upstream release v6.78.0.

github-actions Bot and others added 30 commits November 11, 2026 21:48
no ref
- add override for readdir-glob to update minimatch
no ref

I recommend reviewing this with whitespace changes disabled.

This removes an unnecessary class and just exports the function.
ref https://linear.app/ghost/issue/BER-4121

Shade's skill, docs and README told people to install from npm's `alpha`
tag because `latest` was older. Since publishing moved to `latest`, it's
the other way round: `alpha` is frozen at 0.1.0-alpha.14, so anyone
following the advice, the `build-ghost-app-ui` skill included, installed
a release that's months old. A plain install now gets the newest one, so
the advice names no tag, and the contributor docs say which tag each
package publishes under.
no ref

Ghost Apps is behind a private Labs flag, so Admin can assume a matching
Core for it. Admin still had code for older Cores that no Apps site runs.

- Removed that code and its tests
- Noted in Admin's README and a new Apps AGENTS.md that Apps doesn't
  need older-Core support
- Noted in that AGENTS.md that the Admin API allowlist is temporary,
  until proper app permissions replace it
`@internal/cfg-test-workers` was JavaScript with a hand-written
`index.d.mts`. Its types could drift from the code, and nothing
type-checked the source.

It is now a single `index.ts` with no build step. Its three consumers
load the TypeScript source directly: the Ghost Core database and Admin
acceptance Vitest configs, and the browser E2E Playwright config. The
package also gets its own `test:types`, following
`tools/configs/oxlint/`.

### Testing

- Loaded each consumer config by listing its tests:
  - `ghost`: `vitest list --filesOnly -c vitest.config.db.ts`
- `apps/admin`: `vitest list --filesOnly -c vitest.acceptance.config.ts`
  - `e2e`: `playwright test --list --project=main`
- Set `GHOST_TEST_MACHINE_SHARE=2` and confirmed each of those fails
with the helper's own error, raised from `index.ts`.
- `pnpm --filter @internal/cfg-test-workers test:types`, `pnpm
lint:packages` and `pnpm lint:markdown` pass, as do oxlint, oxfmt and
ESLint on the helper and the three config files.
- Not run locally: the test suites themselves.
…Ghost#32818)

ref https://linear.app/ghost/issue/DYA-242

The phone input's country list named each country with its code straight after it, as in "United Kingdom +44", so in a long list the eye had to find where the name ended before it could read the code. Stripe Checkout, where buyers already pick a country for their phone number, sets the code apart in parentheses, as in "United Kingdom (+44)". The label is built once in the shared package, so Admin and Portal both change with it, and searching by code still finds a country.
no ref

The app SDK kept its own copies of the signed manifest and manifest error
types. Nothing checked them against the contracts package, which defines
the same types. The SDK now imports them from the contracts, so there's
one definition of each and they can't drift apart.
…#32819)

ref https://linear.app/ghost/issue/DYA-241

Each "Save … as" picker in the checkout settings only ever makes one kind of field, and that field almost always gets the same name, so the new field form now starts with it: "Shipping Address", "Recipient Name" or "Phone". It saves a step in the most common setup, and a name searched for in the picker still wins.

The names are in Title Case, as publishers already name their fields: across sites with custom fields, names such as "Shipping Address", "Mailing Address", "Job Title" and "Mobile Phone" outnumber sentence case. A field name is the publisher's own label rather than Ghost's interface copy, so it follows how they write theirs.

Ghost refuses a name another field has, whatever its case, type or status, so a name that's taken isn't suggested and the form starts empty instead. "Shipping Address" and "Phone" already exist on several sites, some of those phones as short text fields the phone picker doesn't offer, so the clash is a real one rather than an edge case.
…ryGhost#32713)

no ref

Core, Admin and the app SDK each wrote the app failure codes out as
plain strings, so changing one in one place could leave the others out
of step with nothing failing. The codes now live in one list:

- Core and the SDK can only use codes on it
- Admin's install screen must handle every code on it
- A Core test catches codes the type-check can't see

Behaviour is unchanged.
ref https://linear.app/ghost/issue/DYA-247

Archiving a custom field doesn't change what checkout asks for. Stripe Checkout, and Portal when a member changes tier, keep asking, and Ghost drops the answers for the archived field. The "Save … as" pickers showed only the field's name, so a setting that no longer saved anything looked as if it worked. A chosen archived field now shows an "Archived" badge, on the picker and in its list.

Archived tiers in the same settings were marked with "(archived)" in their names, so they now get the same badge, keeping one way of saying it on one screen. The closed "Collect for" picker is one line that's cut off when long, so it shows the chosen names with archived ones first and a single badge at the end that always shows: "Archived" for one tier, or how many of several are. The list marks which.

Lists with nothing archived, such as the countries list, keep their default rows. An archived tier is still searched as "Name (archived)", so it's found by "archived" and told apart from an active tier with the same name, as before.
ref https://linear.app/ghost/issue/DYA-25

Whether Ghost handles what Stripe sends it could only be read from request
lines, which are kept for 32 days and don't say which event failed, so a
site whose webhook fails every event looked much like one with a blip. Each
event Stripe sends now records a span with the event's type. The span fails
when Ghost answers Stripe with a failure, including when the event's
signature doesn't show that Stripe sent it, so the feature health dashboard
can hold webhook handling to a target, per site, over a year. The failure is
logged once, as the span's exception line, in place of the two lines the
webhook logged itself.
ref https://linear.app/ghost/issue/DYA-25

A checkout that asks for a shipping address or phone number could only say
whether Stripe was asked, never whether what the buyer typed reached the
member, so a buyer could pay and leave the publisher without an address
they needed and nobody would know. Each checkout a buyer completes now
records a span saying what became of each part it asked for: saved, partly
saved, refused by its field, left with nowhere to go, skipped because the
buyer didn't prove they were the member, or failed. Both the start and the
completion of a checkout say who the buyer is to the site, a new member, a
member who signed in or a member only by the email typed in, so started
checkouts can be set against completed ones for each, and the dashboards can
tell free members upgrading apart from new signups.
ref https://linear.app/ghost/issue/DYA-25

A member moving onto a tier that requires a shipping address or phone number
is asked for them in Portal, and nothing recorded whether they answered,
whether their answers were refused, or whether they were saved, so the team
couldn't tell how often the requirements were met. Each change of plan to a
tier through the members API now records a span saying whether answers came
with it and, for each requirement of the new tier, whether its answers were
saved, partly saved, left out, dropped for an archived field, or lost when
saving failed after the tier changed, the way a completed checkout records
what it asked for. A change refused for its answers fails the span, so
refusals can be counted separately from changes that went through.
ref https://linear.app/ghost/issue/DYA-25

When Ghost failed to handle an event Stripe sent, such as a completed checkout
whose member couldn't be saved, the failure was only logged, so nobody was
told and a site could fail every event for days. Each failure now also goes to
Sentry, where Ghost's setup keeps only the unexpected ones and leaves out
expected refusals such as a webhook whose signature doesn't show Stripe sent
it, so a broken site's errors show up beside every other server error.
fixes
https://linear.app/ghost/issue/PLA-621/keep-the-unit-suite-passing-in-any-file-order

Unit test files share a module registry per worker, so a test that leaks
state, or relies on state another test left, only passes in the order
files happen to run. That has reached main more than once. This fixes
the tests that failed when shuffled, and makes CI shuffle the unit suite
so the PR that adds such a dependency is the one that fails.

CI sets `GHOST_UNIT_TEST_SEED` to the run ID, and `vitest.config.ts`
then shuffles files and the tests inside them. This differs from
`vitest.config.db.ts`, which shuffles only files, with a new seed each
run:

- **Tests too:** several failures were a test relying on an earlier test
in the same file, which shuffling only files never catches.
- **One seed per run:** the unit step retries up to three times, and a
new order on retry could pass and hide the problem. Retries and job
re-runs use the same order, and the printed seed reproduces it locally
(see `docs/contributing/testing.md`).

The fixes, one commit per cause:

- Tests that shared a repository, renderer, cache or service root across
a describe block now set up their own.
- Config, settings stubs, event listeners and nock interceptors are
restored. `mockManager.restore()` no longer re-adds the webmention
discovery mocks, which its own comment reserves for the database suites.
Unit files call `restore()` too, and those leftover mocks broke a test
there. The database setup already re-adds them before and after every
test.
- Helper tests restore the Handlebars helpers and partials they register
(`test/utils/handlebars-state.ts`). Suites that register through Ghost's
helper service get a fresh copy of it, because the service remembers
names and would skip re-registering them later.
- The automations tests import their module after `vi.resetModules()`,
since `vi.mock` has no effect on a module another file already loaded.
- The importer tests give `processZip` disposable copies: when it
failed, it deleted the checked-in zip fixture.

One assertion changed: the recommendations suite for a disabled setting
set it to `true`, and only passed when another suite left an empty
result stubbed. It now disables the setting and expects the helper to
render nothing.

## Testing

- [x] Unit project in normal order, and shuffled at seeds 1 to 10: 804
files pass each time (805 after rebasing, at normal order and seeds 1 to
3)
- [x] `GHOST_UNIT_TEST_SEED=19283746501 pnpm nx run ghost:test:unit
--skip-nx-cache` prints the seed and passes
- [x] `pnpm lint:oxlint`, ESLint on every changed Ghost file, `pnpm
format:check`
- [x] `tsc --noEmit` for `ghost` and `ghost/test`
- [x] Database suites on MySQL, one at a time: integration (77 files,
1,263 tests) and legacy (464 tests) pass. In e2e, 201 of 206 files pass;
the other 5 (`e2e-api/admin/actions.test.js` and four
`e2e-server/*.isolated.test.ts` boot suites, mostly 15s timeouts) pass
when rerun alone, on this branch and on its base
- [x] The database tests that call `mockManager.restore()` inside a test
pass: `content-import-job`, `members`, and the email-service `cards` and
`batch-sending` tests
closes
https://linear.app/ghost/issue/PLA-550/prevent-new-hidden-dependencies-in-service-implementations

The service dependency rules only applied to services marked `migrated`,
so a new hidden dependency in any other service passed CI. They now
apply to every service.

- **One scan.** `pnpm lint:boundaries` runs
`tools/scripts/ci/check-boundaries.ts`, and the `gx services` reports
read the same run. The separate audit mode and
`GHOST_SERVICE_DEPENDENCY_AUDIT` are gone.
- **Known violations.** The 352 existing violations are listed in
`.dependency-cruiser-known-violations.json`. Lint fails on a new
violation, a moved file, a stale or duplicate entry, and any entry for a
migrated service. The file should only shrink.
- **Four services are deferred.** `automations`, `members`,
`members-metafields` and `stripe` change too often for a file-level
list: they added most of the new violations over the previous 30 days,
and a list covering them went stale within a day. Their 235 violations
stay in reports and in the lint summary, but do not fail lint. A service
leaves the list when it is migrated.
- **Computed imports.** The scan only follows literal module names, so
`import/no-dynamic-require` now rejects a computed `require()` or
`import()` in service files. Two existing uses load an email template by
name from their own folder and keep a narrow exception.

CODEOWNERS covers the rule config, the known-violations file and the
checker.

Not covered here: removing a service's `migrated` marker together with
its lint path still passes. That is the root contract rather than
dependencies, and follows separately.

Validation:

- [x] `pnpm lint:boundaries`: 6029 modules, 352 known violations, 235
deferred
- [x] `pnpm format:check`, `pnpm lint:oxlint`, `pnpm lint:docs`
- [x] `tools/scripts`: `pnpm test:unit` (341 pass), `pnpm test:types`,
`pnpm lint`
- [x] `tools/gx`: `pnpm test:unit` (126 pass), `pnpm test:types`, `pnpm
lint`
- [x] The service inventory test (98 pass)
- [x] Manual check: 19 bypass attempts against the real tree are
rejected, including new and moved files, dynamic imports, re-exports,
nested indexes, a dependency routed through a new `server/lib` file, and
known-violation entries for migrated or deferred services
- [ ] `pnpm check` did not pass locally. Format and lint pass. 19 test
files failed in the parallel run and each passes when run alone; two
gift-preview files need a longer timeout
## Why

Part of the gradual JavaScript → TypeScript migration of Ghost core, one
small, faithful conversion at a time. This PR starts on
`ghost/core/server/api/endpoints/utils/validators/input/`, converting
the five input validators whose dependencies are all typed. Types only;
no behaviour change.

## What

Renamed with `git mv`, types added, CommonJS export shape
(`module.exports = {...}`) kept, so the lazy getters in
`validators/input/index.js` and the API framework keep working with zero
caller edits:

| Old | New | Source lines on `main` |
| --- | --- | --- |
| `validators/input/files.js` | `validators/input/files.ts` | 7 |
| `validators/input/media.js` | `validators/input/media.ts` | 11 |
| `validators/input/setup.js` | `validators/input/setup.ts` | 17 |
| `validators/input/oembed.js` | `validators/input/oembed.ts` | 18 |
| `validators/input/users.js` | `validators/input/users.ts` | 23 |

Total 76 source lines. Edits are `require` → `import`
(`@tryghost/debug`, `@tryghost/tpl`, `@tryghost/errors`, the TypeScript
`services/limits`) and parameter types: `apiConfig: unknown` (name kept)
and `frame` typed with `Frame` from `@tryghost/api-framework`, following
`serializers/input/member-commenting.ts`: a local alias such as `type
UsersFrame = Frame<{ data: { password: Array<...> } }>` where the
validator reads `frame.data`, plain `Frame` for `setup` (it only reads
`frame.options.context`), and the type-level intersection `Frame & {
file: { size: number } }` for the upload validators, since `Frame.file`
is `unknown`. `const debug = require('@tryghost/debug')(name)` becomes
`import debugFactory from '@tryghost/debug'; const debug =
debugFactory(name);`, the same pattern as
`email-analytics/lib/queries.ts`.

`service-inventory.yaml`: the 5 path lines naming `files.js`, `media.js`
and `oembed.js` now point at the `.ts` files.

`files` and `media` are short enough that GitHub shows them as delete +
add (below git's default 50% rename similarity). They were moved with
`git mv`; `git diff -M20% origin/main...HEAD --stat` pairs them:

```
 .../utils/validators/input/{files.js => files.ts}         |  7 +++++--
 .../utils/validators/input/{media.js => media.ts}         |  9 ++++++---
 .../utils/validators/input/{oembed.js => oembed.ts}       |  9 ++++++---
 .../utils/validators/input/{setup.js => setup.ts}         | 11 +++++++----
 .../utils/validators/input/{users.js => users.ts}         | 15 +++++++++++----
 ghost/core/server/services/service-inventory.yaml         | 10 +++++-----
 6 files changed, 40 insertions(+), 21 deletions(-)
```

Converted tests: none. No unit test imports these five files (the
existing `validators/input/*.test.js` cover `pages`, `posts`, `tags` and
`webhooks`).

Not converted from this directory: `password_reset`, `invitations`,
`automated_emails` and `settings` (`@tryghost/validator` has no type
declarations; every existing TypeScript import of it uses
`@ts-expect-error`), `labels`, `members`, `snippets`, `tags`, `tiers`,
`webhooks` (depend on the JavaScript `../utils/json-schema`), `pages`,
`posts` (JavaScript `../utils/json-schema` and `models`), `invites`
(JavaScript `models`), `automation_email_previews` (JavaScript
`lib/lexical`), `index` (lazy-getter index of JavaScript validators).

**Revision (review feedback):** the second commit replaces the ad-hoc
structural `frame` shapes with the `Frame` type from
`@tryghost/api-framework`. Types only; no TypeScript caller passes a
plain object to these validators, so `Frame`'s private field breaks
nothing (`pnpm test:types` passes). All checks below were re-run on the
new head.

## How tested

From `ghost/`:
- `pnpm test:types`: passes
- `pnpm lint:code`: passes
- `pnpm test:single
test/unit/server/services/service-inventory.test.ts`: passes (98 tests)
- `pnpm test:unit`: the only failures are `mailgun-client.test.js`,
`ghost-mailer.test.js` and `mailgun-email-suppression-list.test.ts`,
which also fail on `main` in this environment
- A throwaway (uncommitted) vitest check loaded the five modules through
`validators/index.js`: same exported method names as before;
`oembed.read` rejects with `BadRequestError` for a blank url,
`setup.updateSetup` throws `NoPermissionError` without a user,
`users.changePassword` rejects with `ValidationError` on mismatch and
returns `undefined` on match.

Covered by CI:
`test/e2e-api/admin/{files,media,oembed,users,authentication}.test.js`.
## Why

Part of the gradual move of Ghost Core to TypeScript ([codebase
direction](https://github.com/TryGhost/Ghost/blob/main/docs/codebase/direction.md)).
These six Admin API output mappers are the ones in
`serializers/output/mappers/` with no JavaScript dependencies (only
`lodash`, which existing TypeScript in `ghost/core` already imports), so
they convert without casts or suppressions.

## What

Types-only conversion of 6 files in
`ghost/core/server/api/endpoints/utils/serializers/output/mappers/` (152
source lines on `main`):

| Old | New |
| --- | --- |
| `settings.js` | `settings.ts` |
| `integrations.js` | `integrations.ts` |
| `mentions.js` | `mentions.ts` |
| `email-batches.js` | `email-batches.ts` |
| `snippets.js` | `snippets.ts` |
| `email-failures.js` | `email-failures.ts` |

- `frame` is typed with `Frame` from `@tryghost/api-framework` (`import
type`), following `serializers/input/member-commenting.ts` on main.
`model` gets a structural type describing what each mapper reads from
`toJSON(...)`. No logic changes and no new runtime statements.
- `require('lodash')` becomes `import _ from 'lodash'`, matching the
merged `input/utils/clean.ts`.
- Each file keeps its `module.exports = ...` shape, so
`mappers/index.js`, `output/emails.js`, `output/settings.js` and other
JavaScript callers are unchanged.
- `snippets`: the JSDoc `@param`/`@returns`/`@typedef` comments become
the TypeScript parameter type. The `SerializedSnippet` fields keep their
original types, and the return type is inferred from them. The JSDoc
`import('bookshelf').Model` is replaced by a structural type: no
TypeScript file in `ghost/core` imports `bookshelf` types, and their
`Model.toJSON()` returns `any`.
- Model types are written inline on the parameters. `mentions` has no
imports, so TypeScript treats it as a global script, and a named alias
there would be global.
- `service-inventory.yaml`: 3 path lines updated (`integrations` ×2,
`mentions` ×1).

After stripping types with esbuild, each `.ts` file produces the same
JavaScript as the original `.js` file. The only difference is the
`lodash` import line in `settings`, `email-batches` and
`email-failures`. I also loaded the files through `tsx` and through
`tsc`'s CommonJS output: both export the same function and return the
same results as before.

`snippets.ts` is below git's 50% rename similarity, because its JSDoc
was replaced by TypeScript syntax. GitHub therefore shows it as a delete
plus an add. The other five are shown as renames. `git diff -M20%
origin/main...HEAD --stat`:

```
 .../mappers/{email-batches.js => email-batches.ts} |  8 +++--
 .../{email-failures.js => email-failures.ts}       |  8 +++--
 .../mappers/{integrations.js => integrations.ts}   | 12 ++++++-
 .../output/mappers/{mentions.js => mentions.ts}    |  2 +-
 .../output/mappers/{settings.js => settings.ts}    |  4 +--
 .../output/mappers/{snippets.js => snippets.ts}    | 37 +++++++++-------------
 ghost/core/server/services/service-inventory.yaml  |  6 ++--
 7 files changed, 44 insertions(+), 33 deletions(-)
```

Converted tests: none. No unit test imports these files directly.
`test/unit/api/endpoints/utils/serializers/output/mapper.test.js`
exercises `integrations`, `snippets`, `email-batches` and
`email-failures` through the still-JavaScript `mappers/index.js`, so it
stays JavaScript (describe/it counts unchanged).

Not converted from this directory (they depend on JavaScript modules):
`authors`, `images`, `oembed`, `actions`, `pages`, `tags`, `users`,
`index`, `emails`, `newsletters`, `offers`, `activity-feed-events`,
`comments` and `posts`. Open PRs also touch `comments` and `posts`.

**Review follow-up (second commit):** at review, the ad-hoc `frame: {
options?: unknown }` types were replaced with the shared `Frame` type in
`integrations`, `snippets`, `email-batches` and `email-failures`.
`mentions` and `settings` take no `frame`. `Frame` has an ES private
field, so a TypeScript caller passing a plain object would stop
compiling. The only TypeScript caller is
`test/integration/services/email-service/recipient-accounting.test.ts`,
which loads `email-batches` with `require()` (untyped), so it is
unaffected. `pnpm test:types` passes. The `import type` is erased, so
the emitted JavaScript is unchanged.

## How tested

From `ghost/`, on the current head:
- `pnpm test:types`: passes
- `pnpm lint:code`, `pnpm lint:test`: pass
- `pnpm test:single` on the 19 unit tests that load these mappers
through the output serializers (`output/*.test.*`,
`server/.../output/*.test.*`, `output/mappers/{comments,users}.test.*`,
`services/mentions/service.test.js`,
`services/email-service/email-service-wrapper.test.js`): all pass
- `pnpm test:single
test/unit/server/services/service-inventory.test.ts`: passes

On the first commit:
- `pnpm test:unit`: the only failures are `mailgun-client.test.js`,
`ghost-mailer.test.js` and `mailgun-email-suppression-list.test.ts`,
which also fail on `main` in this environment

Covered by CI:
`test/e2e-api/admin/{integrations,snippets,mentions,settings,emails}.test.js`,
`test/e2e-api/content/settings.test.js`,
`test/integration/url-serialization.test.js`,
`test/integration/services/email-service/recipient-accounting.test.ts`.
… a check (TryGhost#32823)

ref https://linear.app/ghost/issue/DYA-244

Every row of a list that takes one answer started with an empty radio circle, a column of identical circles down the left that said little, since only one row is ever picked. The list works as a menu: picking closes it. So, as Apple's menus do, rows now keep the marker's space at the start, keeping their text in line, and only the picked row shows a check there, in the site's accent colour. Lists that take several answers keep their checkboxes, the cue that more than one can be picked.

The marker has no border at all rather than a transparent one, as high-contrast modes draw transparent borders in the text colour, which would have made every row a box, as in a list that takes several. That also leaves the "(None)" row's own hiding rule with nothing to hide, so it goes. Portal's script is about 100 bytes smaller gzipped.

The tick in a multi-choice checkbox sat a pixel above the middle of its box on a 2x screen, and the single-choice check, which started from the same position, sat two to three pixels above the middle of the row's text. Chrome snaps the tick to whole pixels, so the offsets were measured at 1x, 2x and 3x and the ones closest to centred at all three were chosen: the checkbox tick is now centred at 2x and within a pixel at 1x and 3x, and the check is within a pixel of the text's middle at every scale.
ref https://linear.app/ghost/issue/HKG-2129

- Gives us a local setup to find what breaks before Ghost(Pro) serves one site from several Ghosts
- The browser only talks to the Admin dev server, so it routes between the two: X-Ghost-Target picks a Ghost, and without it they take turns
- Ghost 2 starts after Ghost 1 answers, so only one sets up the database and runs migrations
- Ghost itself is unchanged, so staging and production aren't affected
- This is the initial setup, so we can start testing on local. It’ll definitely evolve as we get more clarity on what the final setup, for multi container, on staging and production will look like.
ref https://linear.app/ghost/issue/HKG-2069

- The `db/media/inline` endpoint picked the default domains, logged and
dispatched the media inliner job itself. It was the only code outside
services and boot doing that, so its unit test had to start and stop a
real jobs service.
- The media inliner now has `startInlining(domains)`, and its root passes
in a dispatcher that looks the jobs service up on each call, as the
endpoint did. The endpoint just calls the service.
- This is a refactoring. Nothing changes in production.
rob-ghost and others added 27 commits November 16, 2026 16:49
ref https://linear.app/ghost/issue/DYA-246

Portal can't carry every country's flag in its script, which every page of every site downloads, and an emoji flag shows as two letters in Chrome and Edge on Windows. Portal's build now publishes each country's flag as its own file beside the script, copied from the artwork Admin draws its flags from, so Portal can show one flag by its URL and a reader downloads only that flag. Because the flags are published with the script, a Portal always finds the flags it was built with, whatever version of Ghost the site runs, so this needs no change to Ghost and no new version line for Portal. A copy of Portal hosted elsewhere needs the flags folder beside its script too.
ref https://linear.app/ghost/issue/DYA-246

Portal's phone input has shown the calling code alone since its emoji flag was removed, as Windows has no flag emoji. A flag is a strong cue for the country picked, so the input now shows the country's flag beside its code, as an image that looks the same in every browser and matches Admin's. Several countries share a calling code, so the flag is the country's rather than the code's, by the rules Stripe's and other phone inputs follow: the country a member picked, or the one the number's own digits place it in, and the code's main country only when neither says. A country can't be shown without a flag being published for it, as that no longer compiles. A soft grey of the flag's shape holds its place before a country is known and while the flag loads, so the code doesn't move. Where a flag can't be loaded, as with a copy of Portal hosted without its flags, the input shows the code alone, as it did before. The request for a flag names no page, since the flag asked for already says which country a member's number is from. Portal's script grows by under 400 bytes gzipped, and showing a flag costs a reader one request of under a kilobyte.
no ref

Follow-up to TryGhost#32949, which left a few TryGhost/framework packages one patch
release behind. This brings every framework package Ghost depends on to its
latest version, so they all come from the same set of releases.

- catalog: @tryghost/errors 3.4.8, pretty-cli 3.4.4, security 4.0.4,
  tpl 2.3.22, validator 3.2.23
- ghost: @tryghost/express-test 2.3.23, @tryghost/zip 4.0.3
- patch changeset for @tryghost/adapter-base-sso, which depends on
  @tryghost/errors
…host#31393)

no ref

knex-migrator 6.4 loads TypeScript configs and exports `defineConfig`, so
MigratorConfig is now MigratorConfig.mts, an ES module whose default export
is type-checked against the shape knex-migrator expects. Unbuilt, the root
knex-migrator scripts preload tsx, which compiles it to CommonJS; 6.4.2
unwraps that compiled default export. tsc emits a real ESM
MigratorConfig.mjs for built trees, which ships in the package and the
archive. Its imports use explicit .js paths so they resolve both ways.

MigratorConfig now hands knex-migrator the knex options from configure()
rather than the raw `database` subtree, so migrations run with the same
client settings as the app: SQLite useNullAsDefault and pool pragmas,
Ghost's better-sqlite3 patches, and MySQL's forced timezone/charset.
knex-migrator's own normalisation becomes a no-op, and as 6.4 no longer
mutates the config it is given, the cloneDeep guard is gone.
applyBetterSqlite3Patches is now idempotent, since configure() runs once
for the app and once for the migrator.

knex-migrator 6.4.2 depends on better-sqlite3 ^13.1.1, so Ghost moves to
13.1.1 to keep a single copy, and the override that pointed knex-migrator's
copy at Ghost's is gone.

signed-webhook, explore-ping and the webhooks test now import the typed
@tryghost/version instead of requiring it with hand-written types.
…32953)

no ref

The latest TryGhost/framework releases ship TypeScript declarations for
request, validator, zip, express-test, mw-error-handler and others, so
Ghost no longer needs its own stand-ins for them. Every framework package
Ghost depends on is now on its latest version.

- Removed the local module shims for request, validator and promise (the
  promise shim was still hiding the real types from the previous bump),
  the "lacks type definitions" suppressions, and the hand-written zip
  types
- The remote flags service now uses the request package's own response
  types. Its stand-in typed response headers as plain strings, but got's
  headers can be string arrays (set-cookie)
- The default scheduler adapter now types its request options and errors
  with the request package's types. Before, it passed an untyped HTTP
  method straight to got through an `any` options object
towards https://linear.app/ghost/issue/NY-1792

We notify the automation system about potential automations with
`notify()`.

Before this change, `notify()` didn't support "label added" automations.
Now it does.

Nothing calls this yet—that's coming soon!

No user impact expected.
towards https://linear.app/ghost/issue/NY-1792

No user impact expected.

Before this change, if we tried to run "label added" automation steps,
we'd throw a "not implemented" error.

After this change, we run them!

This doesn't actually trigger those automations yet, nor does it bail
out if the label is removed. Those are upcoming changes.
…ryGhost#32858)

no ref

_We should only merge this after TryGhost#32856 and TryGhost#32857 are deployed._

We've released this. Let's remove the flag.
closes https://linear.app/ghost/issue/NY-1796

Behind the Lead Magnets Labs flag, publishers can start a new automation
with the **Label added to a member** trigger and pick or create a label.
The list refreshes each time the picker opens.

The API work is coming separately. For now, clicking Save or Publish
checks the label and leaves the draft unsaved.

## Screenshots

### First item — Trigger chooser

![Label added to a member in the trigger
chooser](https://github.com/user-attachments/assets/7a262465-dbc6-4402-afd9-df364c8d7b9b)

### Second item — Label picker

![Search results and the option to create a
label](https://github.com/user-attachments/assets/2396a9d9-2ce5-40f3-9cac-2073ce3a01f6)

![A deleted label with a prompt to choose
another](https://github.com/user-attachments/assets/9838129f-2273-43a7-ab3f-f9c277573360)

### Third item — Save and Publish validation

![Publish highlights the missing
label](https://github.com/user-attachments/assets/b0e448b9-2151-4b08-abc1-5e61b471a592)

![Publish shows the temporary error with a valid label
selected](https://github.com/user-attachments/assets/8847b699-a388-4223-bdaa-bcaf0ae7a648)

## Verification

- Saved, edited, and published automations for all three existing
triggers in Ghost Admin with Lead Magnets on and off.
- Verified label search, creation, and replacement after deletion.
Confirmed that Save and Publish leave label-triggered drafts unsaved.
- All 253 automation browser acceptance tests passed.

Co-authored-by: Evan Hahn <evan@ghost.org>
closes https://linear.app/ghost/issue/NY-1792

When a label is added to a member, we now trigger any associated
automations.

You still can't actually _create_ these automations yet, so this should
have no user impact.

I'm not sure if this is performant, but I think we should merge this and
then measure it.
…TryGhost#32922)

closes https://linear.app/ghost/issue/NY-1783

This updates the API to support this new trigger type.

Turns out most of this work was already done in prior commits.

No user impact expected (unless the feature flag is on).
closes https://linear.app/ghost/issue/NY-1808

Just adding a test.

This was written entirely by GPT-6.1 Terra with the following prompt:

> Add a test for "label added" automations in
`e2e/tests/admin/automations/automations.test.ts`, following the pattern
of other tests in that file. The test should be the very last one in the
block, added at the end of the file.
towards https://linear.app/ghost/issue/NY-1809

Just a rename for clarity.

I think this is a useful change on its own, but will also make [an
upcoming change](https://linear.app/ghost/issue/NY-1809) easier.
no ref

zod ships separate ESM and CJS builds. Core's compiled TypeScript require()s
the CJS build, while the ESM workspace packages it loads (checkout, i18n,
app-contracts, metafield-types, metafield-csv, adapter-base-upgrade) import
the ESM build, so production loaded both copies. zod 4's instanceof checks
work across builds, so this only cost memory: about 3MB of heap after boot.

The patch points every zod export at the ESM build, which require() loads
natively on Node 22. Dev was unaffected because tsx compiles everything to
CJS, so this only changes what production loads. Re-create the patch on each
zod bump.
…32957)

ref TryGhost#32705

css-tree was required when ghost_head loaded, and every site has an
accent color (default #FF1A75), so the parser was always loaded even
though almost every value is a plain hex color.

- Hex values (#rgb through #rrggbbaa) are emitted as-is. Admin's color
  picker writes hex, css-tree serializes it unchanged, and it can't
  contain `;`, `}`, `<` or escapes.
- css-tree is now required only on first use, for non-hex values
  (rgb(), var(), etc. set via the API or an import), and results are
  still cached per value.
fixes https://linear.app/ghost/issue/PLA-605/run-definemethod-schemas-in-the-api-framework-pipeline

Make defineMethod schemas executable through the pipeline so inferred
request types are backed by runtime validation before schema callbacks run.

Preserve serializer compatibility and authorization before cache access,
while avoiding unused body copies and cache-key work.
)

no ref

Every Ghost process loaded libphonenumber-js's full metadata at boot,
because core imports the @tryghost/metafield-types root, yet it is only
needed once a phone number is read: a phone custom field write or a
Stripe checkout phone. Most processes never do either.

The phone rules are synchronous zod transforms, so a dynamic import()
would have made the whole value API async. Instead a `#phone-lib`
subpath import picks a variant by condition: Node requires the library
on first use, while `browser` and default (bundles, jsdom tests) keep
the static import. A booted Ghost no longer holds it: heap drops
~2.7 MB and median RSS ~3.5 MB.
…#32959)

no ref

The fake Mailgun server always returned an empty events list, so
newsletters sent locally never showed deliveries, opens or clicks, and
email analytics couldn't be exercised without a real Mailgun account.
The standalone mailgun-mock-server in TryGhost/Toolbox covered this but
needed Redis, SQLite and its own UI, and lived outside the repo.

- Sends now record a delivered (or bounced) event per recipient, plus
  delayed opens when open tracking is on, served through a paged events
  API shaped the way mailgun.js reads paging.next. Per-recipient
  Message-Ids are resolved, so events match what Ghost stored.
- Tracked /r/ links can be followed for each recipient, keeping the
  link's Host header so the Docker container reaches host-run Ghost.
- Send failures and response delays are opt-in. Settings can be changed
  at runtime via /__fake/config or set with FAKE_MAILGUN_* env vars.
- Browser tests keep deterministic defaults (delivered only);
  dev:fake-mailgun turns on realistic opens and clicks.
ref https://linear.app/ghost/issue/DYA-25

Reporting webhook failures to Sentry relied on Ghost's Sentry setup keeping
only the unexpected ones, but that setup only filters Ghost's own errors and
keeps every other error, Stripe's included. A publisher who revoked Ghost's
access to their Stripe account fails every event Stripe sends until they
reconnect, so one such site sent Sentry an error for each event and each retry,
enough to open an incident. Stripe's errors for a key that no longer works on
the publisher's account are now kept out of Sentry, as only the publisher can
fix them. Every other failure is still reported, including Stripe refusing a
request Ghost made, and every failure is still recorded on the webhook's span
and its exception line.
ref https://linear.app/ghost/issue/DYA-25

A span that failed before setting any attribute, such as a Stripe webhook
whose signature doesn't show Stripe sent it, logged its exception with empty
attribute groups. Grafana turns an empty object into a field of that name, and
its logs panel reads a field named labels as each line's labels, so any page
holding such a line failed to show, saying it needed parsed labels to find
common labels. An exception line now leaves out the attribute groups it has
nothing in.
closes https://linear.app/ghost/issue/PLA-610/warn-on-unknown-config-keys-instead-of-failing-even-in-strict-mode

- TryGhost#32638 added `knownKeys()` for the `spam` config section, but SCHEMA.md
  described only `z.object()` and `z.strictObject()` for closed sections
- once strict config becomes the default in Ghost 7, picking `strictObject`
  for a section self-hosters write by hand would turn a leftover or misspelled
  key into a failed boot
- the guide now lists all three options and when to use each: `z.object()`
  strips unknown keys silently, `knownKeys()` warns about them and strips them
  (it fails the parse only under test), and `z.strictObject()` rejects them
…Ghost#32963)

ref https://linear.app/ghost/issue/PLA-602

Files in shared/config/schema/ describe config shapes, so they should know
feature names but never feature code. The existing shared-not-server rule did
not stop them reaching into the rest of shared/: primitives.ts imported the
config loader's utils, which pulls in fs, jsonc-parser and nconf types. A new
config-schema-zod-only boundary rule now limits them to zod and each other.
primitives.ts reads NODE_ENV and writes its unknown-key warning itself, and the
now-unused reportUnknownKeys is gone.
ref https://linear.app/ghost/issue/HKG-2092

The rollout dashboard compares outbox hand-offs with job completions, but
only the boot line said whether a site had the outbox on, so completions
from every site swamped the comparison. The started, completed, failed and
interrupted lines now carry structured system fields with the event, job
type and outbox mode, so each panel can filter to sites with the outbox on.
ref https://linear.app/ghost/issue/HKG-2092

Zuul sets the outbox poll per site, and the lease decides when another
process takes a stalled job. Neither showed in the logs, so after a config
change the only check was the query rate on each database server. The
jobs.started line now carries poll_interval_ms and lease_ms when the outbox
is on, so each site's settings can be checked after it restarts.
ref https://linear.app/ghost/issue/DYA-254/make-shipping-address-and-phone-collection-generally-available

Publishers can now ask for a shipping address and a phone number at Stripe Checkout, for the tiers that need them and the countries they ship to, and keep the answers on each member in custom fields, ready to filter and export. A paid member changing onto a tier that asks is asked in Portal as part of the change, and Settings can create phone custom fields, which keep a number in international format with its country code. Both were built behind private Labs flags, and every site now gets them, while plans that can't connect Stripe still don't see collection. Both flags move to the released list rather than going away, so Ghost(Pro) can still switch either off through its remote flags in the first weeks, and their checks and tests stay until the flags are removed. Both Labs toggles go, as Settings can no longer save either flag, and so does every test's request to turn them on, which is now what every site already runs, and the browser test for collection switched off, a state Labs can no longer reach. Admin's test fixtures list both flags as on, as Ghost reports them.
ref https://linear.app/ghost/issue/DYA-254/make-shipping-address-and-phone-collection-generally-available

Releasing a field type by removing its entry from FIELD_TYPE_FLAGS left Ghost(Pro) no way to take the type back, since Admin deploys the change on merge and from then on, like every server running it, no longer asks about the flag. The guide now moves the flag to the released list first, as other Labs flags go, so a remote flags entry can still switch the type off while it settles in, and removes the entry and the flag together once it has.
@andreascreten andreascreten self-assigned this Nov 18, 2026
@andreascreten
andreascreten merged commit 00f5188 into main Nov 18, 2026
64 of 66 checks passed
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.