Skip to content

fix(core): refine unknown dependencies message token display#16493

Merged
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
shahnoormujawar:fix/unknown-dependencies-message-formatting
Mar 4, 2026
Merged

fix(core): refine unknown dependencies message token display#16493
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
shahnoormujawar:fix/unknown-dependencies-message-formatting

Conversation

@shahnoormujawar

Copy link
Copy Markdown
Contributor

PR Checklist

  • The commit message follows the guidelines
  • Tests for the changes have been added / updated
  • Docs have been added / updated (not applicable)

PR Type

  • Bugfix
  • Feature
  • Code style update
  • Refactoring
  • Build related changes
  • CI related changes

What is the current behavior?

When Nest cannot resolve a dependency, the error message produced by
UNKNOWN_DEPENDENCIES_MESSAGE has two minor rough edges:

  1. For import-type issues (where the dependency name is genuinely unknown),
    the word "dependency" is used as a generic stand-in, resulting in phrasing like:

    Please make sure that the argument dependency at index [0] …

  2. The message ends with "context", while users typically reason
    about their applications in terms of modules, e.g.:

    … is available in the RootTestModule context.

Discussion reference: #16491


What is the new behavior?

  • The token name is displayed only when it is actually defined.
    If the name is unknown, the message now reads:

    argument at index [N]

    (without a misleading placeholder word)

  • "context" is replaced with "module" so the phrasing aligns with
    how users reason about application structure.

Before

Nest can't resolve dependencies of the CatService (?, CatService).
Please make sure that the argument dependency at index [0] is available in the current context.

After

Nest can't resolve dependencies of the CatService (?, CatService).
Please make sure that the argument at index [0] is available in the current module.

String and symbol tokens continue to render correctly
(e.g. "FooRepository", Symbol(MY_TOKEN)).


Does this PR introduce a breaking change?

  • No

This is strictly a developer-experience wording refinement.
No public APIs, runtime behavior, or error types are changed.

All unit and integration tests pass.

@coveralls

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build c687ad7b-65b1-46f5-afc8-8a24a1e0c43f

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.863%

Totals Coverage Status
Change from base Build 20ed658b-fbeb-42a7-baef-09addf89e807: 0.0%
Covered Lines: 7473
Relevant Lines: 8316

💛 - Coveralls

Comment thread packages/core/errors/messages.ts
@kamilmysliwiec kamilmysliwiec merged commit c9268ff into nestjs:master Mar 4, 2026
2 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.

4 participants