Skip to content

Conversation

@JoeNutt
Copy link

@JoeNutt JoeNutt commented Nov 1, 2025

Here’s a concise PR body you can paste:

Treat non-static dependency trees as scoped in get(); instruct consumers to use resolve().

Adds focused tests under NestApplicationContext spec to cover implicit request scope via enhancers.

Closes #15836.

PR Checklist

PR Type

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Calling module.get on a class whose dependency tree is implicitly non-static (e.g., due to a request‑scoped pipe/guard) returns a prototype-only instance with undefined injections, rather than throwing. Users don’t get guidance to use resolve().
Issue Number: #15836

What is the new behavior?

module.get now throws InvalidClassScopeException for non-static dependency trees (implicit request scope), instructing users to use resolve(). module.resolve continues to instantiate per-context correctly. Added tests to cover both get (throws) and resolve (works).

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

  • Core change: abstract-instance-resolver.ts (guard in find to also check !wrapperRef.isDependencyTreeStatic()).
  • Tests: nest-application-context.spec.ts (two specs under “implicit request scope via enhancers”).

Treat non-static dependency trees as scoped in get(); instruct consumers to use resolve().\n\nAdds focused tests under NestApplicationContext spec to cover implicit request scope via enhancers.\n\nCloses nestjs#15836.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 513890a5-e0b5-48f6-83b7-3f896faedccc

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 88.939%

Totals Coverage Status
Change from base Build addc9f43-f31d-4145-9327-14d30a76e998: 0.01%
Covered Lines: 7325
Relevant Lines: 8236

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

missing injection token in createTestingModule causes undefined controller dependencies

3 participants