Skip to content

Fixed missing image dimensions in meta tags with non-local storage#28773

Open
allouis wants to merge 1 commit into
mainfrom
attractor-fix-INC-300
Open

Fixed missing image dimensions in meta tags with non-local storage#28773
allouis wants to merge 1 commit into
mainfrom
attractor-fix-INC-300

Conversation

@allouis

@allouis allouis commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

ref https://linear.app/tryghost/issue/HKG-1865

  • image dimension lookup in ghost_head routed any /content/images/ URL straight to storage.read(); with an S3-backed adapter (no local disk) read() threw a critical IncorrectUsageError, flooding logs on every page render and dropping social-meta image dimensions
  • getImageSizeFromUrl now catches IncorrectUsageError and falls back to fetching the image over HTTP to determine dimensions
  • local-disk happy path and existing error propagation (NotFoundError etc.) unchanged

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 734f3d80-b13f-477f-89a7-0a38017d88be

📥 Commits

Reviewing files that changed from the base of the PR and between 13fe101 and b842e8c.

📒 Files selected for processing (3)
  • ghost/core/core/server/adapters/storage/S3Storage.ts
  • ghost/core/test/integration/adapters/storage/s3-storage.test.ts
  • ghost/core/test/unit/server/adapters/storage/s3-storage.test.ts

Walkthrough

S3Storage.read() previously always threw an IncorrectUsageError. It is replaced with a working implementation that validates options.path, constructs the S3 object key, issues a GetObjectCommand, converts the response body to a Buffer, and maps S3 not-found responses (NotFound/NoSuchKey) to a NotFoundError. Two new message constants are added for the empty-path and not-found cases. The isNotFound helper is narrowed from boolean to a TypeScript type guard. Unit tests replace the "unsupported" assertion with stubs covering the success path, 404 mapping, and missing-path validation. A new MinIO integration suite adds lifecycle-managed bucket tests covering binary safety, path mapping, error cases, and tenant-prefix isolation.

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title refers to fixing missing image dimensions with non-local storage, but the actual changes implement S3 read() support and HTTP fallback logic in getImageSizeFromUrl. The title describes a problem but not the primary solution. Consider a more specific title like 'Implement S3 read() support and HTTP fallback for image dimension lookup' to accurately reflect the main code changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly relates to the changeset, explaining the problem (missing dimensions with S3), the context (read() being unimplemented), and the solution (implementing read() and adding HTTP fallback).
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch attractor-fix-INC-300

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

@nx-cloud

nx-cloud Bot commented Jun 22, 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 b842e8c

Command Status Duration Result
nx run ghost:test:ci:integration:no-coverage ✅ Succeeded 2m 27s View ↗
nx run ghost:test:ci:integration ✅ Succeeded 2m 6s View ↗
nx run ghost:test:ci:e2e ✅ Succeeded 7m 38s View ↗
nx run ghost:test:ci:e2e:no-coverage ✅ Succeeded 7m 21s View ↗
nx run ghost:test:ci:legacy ✅ Succeeded 2m 49s View ↗
nx build @tryghost/sodo-search ✅ Succeeded <1s View ↗
nx build @tryghost/activitypub ✅ Succeeded 2s View ↗
nx build @tryghost/comments-ui ✅ Succeeded <1s View ↗
Additional runs (10) ✅ Succeeded ... View ↗

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


☁️ Nx Cloud last updated this comment at 2026-06-22 07:00:17 UTC

@allouis allouis force-pushed the attractor-fix-INC-300 branch from a4adeda to 464881e Compare June 22, 2026 06:19
@allouis allouis requested a review from vershwal June 22, 2026 06:20
@allouis allouis force-pushed the attractor-fix-INC-300 branch 2 times, most recently from 0fbef80 to bf8d576 Compare June 22, 2026 06:42
fixes https://linear.app/tryghost/issue/INC-300

- read() was left unimplemented when the adapter was added (9f0c353), as files and media flows never needed it
- image dimension lookups (ghost_head social meta) do call storage.read() for local-style /content/images/ URLs; with S3 configured as the images adapter this threw a critical IncorrectUsageError, flooding logs on every page render and dropping image dimensions
- implemented read() as a native S3 GetObject so the existing image-size flow works unchanged; results are already cached by CachedImageSizeFromUrl, so it's one fetch per image, not per render
- resizing (handle-image-sizes) still doesn't need read under S3: those requests terminate at the CDN and never reach Ghost

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@allouis allouis force-pushed the attractor-fix-INC-300 branch from bf8d576 to b842e8c Compare June 22, 2026 06:45
@allouis allouis marked this pull request as ready for review June 22, 2026 10:55
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.

1 participant