Skip to content

Fixed adapter-manager misreporting missing deps as missing adapter#27765

Merged
allouis merged 1 commit into
mainfrom
fix-adapter-missing-dep-error
May 7, 2026
Merged

Fixed adapter-manager misreporting missing deps as missing adapter#27765
allouis merged 1 commit into
mainfrom
fix-adapter-missing-dep-error

Conversation

@allouis
Copy link
Copy Markdown
Collaborator

@allouis allouis commented May 7, 2026

Node's MODULE_NOT_FOUND errors include a "Require stack" that lists
the calling file's path. The existing heuristic checked whether the
adapter path appeared anywhere in err.message to distinguish
"adapter not found" from "adapter found but has a missing dependency."

Because the adapter's own path always appears in the require stack, the
check always matched, causing missing-dep errors to be silently
swallowed and replaced with a misleading "Unable to find adapter"
message.

Restricting the check to the first line of the error message fixes the
false positive.

no-issue

Node's MODULE_NOT_FOUND errors include a "Require stack" that lists the
calling file's path. The existing heuristic checked whether the adapter
path appeared anywhere in err.message to distinguish "adapter not found"
from "adapter found but has a missing dependency." Because the adapter's
own path always appears in the require stack, the check always matched,
causing missing-dep errors to be silently swallowed and replaced with a
misleading "Unable to find adapter" message. Restricting the check to
the first line of the error message fixes the false positive.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

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: c6436f18-749c-47a3-ac0c-0b6e7e305083

📥 Commits

Reviewing files that changed from the base of the PR and between 3e66d51 and 5b0f1de.

📒 Files selected for processing (2)
  • ghost/core/core/server/services/adapter-manager/adapter-manager.js
  • ghost/core/test/unit/server/services/adapter-manager/adapter-manager.test.js

Walkthrough

This PR modifies the adapter manager's error detection logic to check only the first line of error messages when determining if a module loading failure is due to missing dependencies, avoiding false positives from Node.js's appended require stack traces. The implementation change in adapter-manager.js is accompanied by new test coverage that validates the behavior with a temporary adapter module that requires a non-existent package.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main fix: correcting how the adapter-manager distinguishes between missing adapters and missing dependencies.
Description check ✅ Passed The description is directly related to the changeset, explaining the root cause (require stack appearing in error message) and the solution (restricting check to first line).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 fix-adapter-missing-dep-error

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

@allouis allouis enabled auto-merge (rebase) May 7, 2026 11:16
@allouis allouis merged commit 44af743 into main May 7, 2026
44 checks passed
@allouis allouis deleted the fix-adapter-missing-dep-error branch May 7, 2026 11:37
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