Skip to content

✨ Added boot-time validation functionality support for adapters#29371

Merged
acburdine merged 1 commit into
mainfrom
feat/adapter-validate
Jul 16, 2026
Merged

✨ Added boot-time validation functionality support for adapters#29371
acburdine merged 1 commit into
mainfrom
feat/adapter-validate

Conversation

@acburdine

Copy link
Copy Markdown
Member

ref https://linear.app/ghost/issue/PLA-247/implement-boot-time-adapter-config-validation

  • add new optional static validate method to adapter manager logic
  • validate is passed normalized adapter config options and can optionally throw IncorrectUsageError if configuration options are absent
  • refactor S3/FileStore adapter extensions to leverage Zod schemas for config validation
  • wire up validation to adapterManager init method, called during boot

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adapter configurations for S3 storage, S3 redirects, and route settings now use Zod schemas with normalization and static validation methods. AdapterManager resolves configured adapters and feature variants, validates adapter contracts and configurations, deduplicates equivalent validations, and aggregates failures. Core boot invokes adapter initialization early, with tests covering schema validation, feature discovery, deduplication, and error aggregation.

Possibly related PRs

  • TryGhost/Ghost#29279: Updates the redirects adapter class and contract that S3 redirects validation relies on.
  • TryGhost/Ghost#29320: Updates AdapterManager typing and resolution plumbing used by adapter validation.

Suggested reviewers: jonatansberg, evanhahn, vershwal, 9larsons, rob-ghost

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: boot-time adapter validation support.
Description check ✅ Passed The description is directly related to the changeset and summarizes the adapter validation work.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/adapter-validate

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Jul 15, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 2dbf648

Command Status Duration Result
nx run ghost:test:ci:integration ✅ Succeeded 3m View ↗
nx run ghost:test:integration ✅ Succeeded 2m 53s View ↗
nx run ghost:test:legacy ✅ Succeeded 2m 54s View ↗
nx run ghost:test:e2e ✅ Succeeded 2m 32s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 18s View ↗
nx run-many -t test:unit -p ghost ✅ Succeeded 30s View ↗
nx run-many -t lint -p ghost,ghost-monorepo ✅ Succeeded 18s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded <1s View ↗
nx run @tryghost/admin:build ✅ Succeeded 4s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-16 17:14:09 UTC

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.54037% with 53 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.17%. Comparing base (019e575) to head (2dbf648).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...server/services/adapter-manager/adapter-manager.ts 72.72% 29 Missing and 1 partial ⚠️
...core/core/server/services/adapter-manager/types.ts 0.00% 10 Missing ⚠️
...ost/core/core/server/adapters/storage/S3Storage.ts 92.68% 6 Missing ⚠️
...core/core/server/services/adapter-manager/utils.ts 88.88% 3 Missing ⚠️
...core/server/adapters/redirects/S3RedirectsStore.ts 96.36% 2 Missing ⚠️
...e/core/server/adapters/route-settings/FileStore.ts 93.54% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29371      +/-   ##
==========================================
- Coverage   74.19%   74.17%   -0.02%     
==========================================
  Files        1592     1592              
  Lines      138811   139000     +189     
  Branches    16858    16865       +7     
==========================================
+ Hits       102990   103107     +117     
- Misses      34804    34843      +39     
- Partials     1017     1050      +33     
Flag Coverage Δ
e2e-tests 76.24% <83.54%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ghost/core/core/server/adapters/route-settings/FileStore.ts`:
- Line 31: Update the z.custom schema for getBackupFilePath in FileStore.ts to
validate that the runtime value is callable, and update the z.custom schema for
s3Client in S3Storage.ts to validate an object with a callable send method.
Apply the corresponding predicates at both affected sites so boot validation
rejects invalid values before adapter use.

In `@ghost/core/core/server/adapters/storage/S3Storage.ts`:
- Around line 70-81: Update the multipart byte-count schemas, including
multipartChunkSizeBytes and multipartUploadThresholdBytes, to require integer
values with Zod’s integer validation so fractional configuration fails before
reaching fs.createReadStream highWaterMark.
- Around line 86-88: Update the S3 configuration schema around accessKeyId,
secretAccessKey, and sessionToken to reject partial credential configurations,
matching the credential-pair refinement used by S3RedirectsStore. Ensure
credentials are accepted only when the required key fields are provided
together, rather than allowing incomplete values to fall back to ambient AWS
credentials.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6107e492-f1b8-4249-866d-e7e39fb4eabf

📥 Commits

Reviewing files that changed from the base of the PR and between 2af16d6 and 491e1bd.

📒 Files selected for processing (10)
  • ghost/core/core/boot.js
  • ghost/core/core/server/adapters/redirects/S3RedirectsStore.ts
  • ghost/core/core/server/adapters/route-settings/FileStore.ts
  • ghost/core/core/server/adapters/storage/S3Storage.ts
  • ghost/core/core/server/services/adapter-manager/adapter-manager.ts
  • ghost/core/core/server/services/adapter-manager/types.ts
  • ghost/core/core/server/services/adapter-manager/utils.ts
  • ghost/core/test/unit/server/adapters/storage/s3-storage.test.ts
  • ghost/core/test/unit/server/services/adapter-manager/adapter-manager.test.ts
  • ghost/core/test/unit/server/services/adapter-manager/utils.test.ts

Comment thread ghost/core/core/server/adapters/route-settings/FileStore.ts Outdated
Comment thread ghost/core/core/server/adapters/storage/S3Storage.ts
Comment thread ghost/core/core/server/adapters/storage/S3Storage.ts Outdated
@acburdine
acburdine force-pushed the feat/adapter-validate branch from 491e1bd to d4e570a Compare July 15, 2026 20:43

@allouis allouis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

One small thing - is it worth making the init and validate methods async - so that we allow for the potential of async validation in future?

@acburdine

Copy link
Copy Markdown
Member Author

One small thing - is it worth making the init and validate methods async

Hah so my first local iteration of this actually did that, ultimately I opted to go the simpler route upfront. It wouldn't be difficult to add in later should we need to

@acburdine
acburdine force-pushed the feat/adapter-validate branch 4 times, most recently from 144b7a8 to f680be7 Compare July 16, 2026 16:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ghost/core/core/server/services/adapter-manager/utils.ts`:
- Around line 99-100: Update the adapter resolution logic around the
string-feature branch to retain the selected adapter class while setting
adapterConfig to undefined when settings[featureAdapter] is absent, instead of
unconditionally returning the string. Ensure resolveAdapterOptions validates
that selected class and rejects missing configuration rather than falling back
to the active adapter.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 22145d10-ef18-42e2-9a75-59eb37432ed6

📥 Commits

Reviewing files that changed from the base of the PR and between 144b7a8 and f680be7.

📒 Files selected for processing (10)
  • ghost/core/core/boot.js
  • ghost/core/core/server/adapters/redirects/S3RedirectsStore.ts
  • ghost/core/core/server/adapters/route-settings/FileStore.ts
  • ghost/core/core/server/adapters/storage/S3Storage.ts
  • ghost/core/core/server/services/adapter-manager/adapter-manager.ts
  • ghost/core/core/server/services/adapter-manager/types.ts
  • ghost/core/core/server/services/adapter-manager/utils.ts
  • ghost/core/test/unit/server/adapters/storage/s3-storage.test.ts
  • ghost/core/test/unit/server/services/adapter-manager/adapter-manager.test.ts
  • ghost/core/test/unit/server/services/adapter-manager/utils.test.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • ghost/core/core/server/services/adapter-manager/types.ts
  • ghost/core/test/unit/server/services/adapter-manager/adapter-manager.test.ts
  • ghost/core/core/boot.js
  • ghost/core/test/unit/server/adapters/storage/s3-storage.test.ts
  • ghost/core/test/unit/server/services/adapter-manager/utils.test.ts
  • ghost/core/core/server/adapters/redirects/S3RedirectsStore.ts
  • ghost/core/core/server/services/adapter-manager/adapter-manager.ts
  • ghost/core/core/server/adapters/route-settings/FileStore.ts

Comment thread ghost/core/core/server/services/adapter-manager/utils.ts
ref https://linear.app/ghost/issue/PLA-247/implement-boot-time-adapter-config-validation
- add new optional static `validate` method to adapter manager logic
- validate is passed normalized adapter config options and can optionally throw IncorrectUsageError if configuration options are absent
- refactor S3/FileStore adapter extensions to leverage Zod schemas for config validation
- wire up validation to adapterManager init method, called during boot
@acburdine
acburdine force-pushed the feat/adapter-validate branch from f680be7 to 2dbf648 Compare July 16, 2026 17:02
@acburdine
acburdine merged commit facc2e6 into main Jul 16, 2026
45 checks passed
@acburdine
acburdine deleted the feat/adapter-validate branch July 16, 2026 17:28
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