Skip to content

Fix amazon link card#25560

Merged
9larsons merged 3 commits into
TryGhost:mainfrom
hshiozawa:fix-amazon-link-card
Jun 12, 2026
Merged

Fix amazon link card#25560
9larsons merged 3 commits into
TryGhost:mainfrom
hshiozawa:fix-amazon-link-card

Conversation

@hshiozawa

@hshiozawa hshiozawa commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Summary

This PR resolves the issue described below.

#22417

As documented in the linked issue, images are not displayed in Amazon-embedded content.
This behavior also occurs in the latest version (current HEAD) of Ghost.

Root Cause and Fix

I investigated the problem and confirmed that it can be resolved by introducing metascraper-amazon:

#22417 (comment)

Additional Timeout Issue

Large pages like Amazon sometimes cause fetch requests to time out at the default 2-second limit.
I described this problem in detail here, and extending the timeout resolves it:

#22590 (comment)

--

Please check your PR against these items:

  • I've read and followed the Contributor Guide
  • I've explained my change
  • I've written an automated test to prove my change works

We appreciate your contribution! 🙏


Note

Adds metascraper-amazon to metadata scraping and increases oEmbed page fetch timeout to 10s to improve Amazon link embeds.

  • OEmbed/Metadata fetching:
    • Update core/server/services/oembed/OEmbedService.js:
      • Increase fetchPage request timeout from 2000 to 10000 ms.
      • Include metascraper-amazon in metascraper pipeline for bookmark data extraction.
    • Update core/package.json:
      • Add dependency metascraper-amazon@5.45.10.

Written by Cursor Bugbot for commit efe4c53. This will update automatically on new commits. Configure here.

@coderabbitai

coderabbitai Bot commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Added metascraper-amazon v5.45.10 to ghost/core/package.json dependencies. Integrated metascraper-amazon into two metascraper pipelines in ghost/core/core/server/services/oembed/OEmbedService.js (bookmark-related scraping paths). Increased HTTP fetch timeout in fetchPage from 2000 ms to 10000 ms. No changes to function signatures or exported/public types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Files to inspect:
    • ghost/core/core/server/services/oembed/OEmbedService.js — verify the timeout change and the two pipeline additions are correct and consistent (imports/usage).
    • ghost/core/package.json — confirm dependency entry for metascraper-amazon (version 5.45.10) is correct.
  • Pay attention to import/require statements, duplicated pipeline entries, and any stray typos introduced by the additions.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix amazon link card' directly relates to the main objective of resolving the Amazon embedding issue by adding metascraper-amazon and increasing fetch timeout.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the root cause, the fix with metascraper-amazon, and the timeout issue resolution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e58c16bddb1b73ccb20672da04368b8960275ec3 and efe4c53.

📒 Files selected for processing (2)
  • ghost/core/core/server/services/oembed/OEmbedService.js (2 hunks)
  • ghost/core/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • ghost/core/package.json
  • ghost/core/core/server/services/oembed/OEmbedService.js

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 and usage tips.

@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: 0

🧹 Nitpick comments (1)
ghost/core/core/server/services/oembed/OEmbedService.js (1)

180-191: Consider broader impact of raising the default fetch timeout to 10s

Bumping the default timeout from 2s to 10s will slow failure paths for all embeds that go through fetchPage, not just Amazon, which can affect editor responsiveness and worker utilization if third‑party hosts hang or are very slow. The merge order (...options last) still allows callers to override this default, which is good.

It may be worth:

  • Confirming all call sites that care about latency explicitly set a tighter options.timeout, and/or
  • Considering a more targeted longer timeout for known slow domains (e.g. Amazon) instead of globally.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc7b6c7 and e58c16bddb1b73ccb20672da04368b8960275ec3.

📒 Files selected for processing (2)
  • ghost/core/core/server/services/oembed/OEmbedService.js (2 hunks)
  • ghost/core/package.json (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-26T16:47:28.150Z
Learnt from: troyciesco
Repo: TryGhost/Ghost PR: 24749
File: ghost/core/core/server/services/members/SingleUseTokenProvider.js:3-5
Timestamp: 2025-08-26T16:47:28.150Z
Learning: When checking for dependencies in Ghost project, ensure to look directly in the specific package.json files rather than relying only on automated searches, as otplib dependency exists at line 204 in ghost/core/package.json version "12.0.1"

Applied to files:

  • ghost/core/package.json
📚 Learning: 2025-08-12T18:33:15.524Z
Learnt from: cmraible
Repo: TryGhost/Ghost PR: 24658
File: ghost/admin/package.json:3-3
Timestamp: 2025-08-12T18:33:15.524Z
Learning: In Ghost's admin package.json, third-party packages like ember-cli-postcss, ember-exam, and ember-power-select have their own independent versioning schemes that are unrelated to Ghost's version numbers. Version number coincidences between Ghost versions and these packages should not trigger update suggestions.

Applied to files:

  • ghost/core/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cursor Bugbot
🔇 Additional comments (2)
ghost/core/core/server/services/oembed/OEmbedService.js (1)

283-296: Amazon metascraper integration looks consistent, but verify behavior on non‑Amazon pages

Adding metascraper-amazon at the top of the rules list is consistent with your existing metascraper usage and should enable richer Amazon image extraction while leaving other sites handled by the generic bundles.

A couple of things to double‑check:

  • That the new plugin doesn’t regress metadata for non‑Amazon URLs (since rule order can influence which values “win”).
  • That metascraper’s additional work on Amazon pages doesn’t introduce noticeable delays beyond what the new 10s timeout already allows.

If your new automated test only covers one Amazon URL, consider adding a second from a different Amazon locale or product type to guard against markup variance.

ghost/core/package.json (1)

185-195: metascraper-amazon dependency addition looks consistent with existing metascraper stack

The new "metascraper-amazon": "5.45.10" entry matches the versions of the other metascraper-* bundles you’re already using, and it’s correctly added to ghost/core/package.json alongside the rest of the server‑side metascraper dependencies. No further manifest changes seem necessary here.

Based on learnings, locating and updating this dependency in ghost/core/package.json is the right place for this change.

@hshiozawa hshiozawa force-pushed the fix-amazon-link-card branch from e58c16b to efe4c53 Compare December 1, 2025 09:05
hshiozawa and others added 3 commits June 11, 2026 12:48
ref TryGhost#22417
ref TryGhost#22590

- 5s balances slow-but-alive pages like Amazon against editor paste
  latency when a link is dead
- regenerated the lockfile for the new metascraper-amazon dependency
- covered the amazon ruleset and the fetch timeout with unit tests
@9larsons 9larsons force-pushed the fix-amazon-link-card branch from efe4c53 to 49815a4 Compare June 11, 2026 17:53
@9larsons

Copy link
Copy Markdown
Contributor

Hey @hshiozawa, sorry for the delay here. The changes look good to me and while I think a 2s timeout is reasonable, Amazon pulls are notably slow. I remember looking into this previously. We'll try this out.

@9larsons 9larsons enabled auto-merge (squash) June 12, 2026 15:16
@nx-cloud

nx-cloud Bot commented Jun 12, 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 49815a4

Command Status Duration Result
nx run ghost:test:ci:integration ✅ Succeeded 2m 27s View ↗
nx run ghost:test:ci:e2e ✅ Succeeded 12m 31s View ↗
nx build @tryghost/announcement-bar ✅ Succeeded 1s View ↗
nx build @tryghost/admin-toolbar ✅ Succeeded 1s View ↗
nx build @tryghost/comments-ui ✅ Succeeded <1s View ↗
nx build @tryghost/signup-form ✅ Succeeded <1s View ↗
nx build @tryghost/sodo-search ✅ Succeeded <1s View ↗
nx build @tryghost/activitypub ✅ Succeeded 1s View ↗
Additional runs (13) ✅ Succeeded ... View ↗

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


☁️ Nx Cloud last updated this comment at 2026-06-12 15:32:16 UTC

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.76%. Comparing base (89604d0) to head (49815a4).
⚠️ Report is 40 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #25560   +/-   ##
=======================================
  Coverage   73.76%   73.76%           
=======================================
  Files        1541     1541           
  Lines      132268   132269    +1     
  Branches    15827    15827           
=======================================
+ Hits        97569    97573    +4     
+ Misses      33711    33709    -2     
+ Partials      988      987    -1     
Flag Coverage Δ
admin-tests 54.69% <ø> (+0.02%) ⬆️
e2e-tests 73.76% <100.00%> (+<0.01%) ⬆️

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.

@9larsons 9larsons merged commit e0a2907 into TryGhost:main Jun 12, 2026
51 checks passed
@hshiozawa

Copy link
Copy Markdown
Contributor Author

Thanks for the review and merge!

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