fix(container): Any / Any|None params are not injectable (v26.06.96)#126
Merged
Conversation
An __init__ param typed Any (e.g. 'registry: Any = None') hit the plain-class fast path and called self.resolve(Any), matching whatever bean was registered under Any (e.g. an '@bean -> Any' cache health indicator) and injecting the wrong object. Treat Any like 'type': raise NoSuchBeanError so the caller uses the parameter default.
Same root cause as the Any fast-path: a param typed 'Any | None' (e.g. a @bean method's 'metrics: Any | None = None') reduced to resolve(Any) in the Optional branch, injecting whatever bean was registered under Any (a CacheHealthIndicator) into RuleEngineService.metrics -> 'has no attribute counter'. Return None for Optional[Any] so the parameter default is used.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #124/#125. A param typed
AnyorAny | Nonewas autowired to whatever bean was registered underAny(e.g. an@bean -> Anycache health indicator), injecting the wrong object —'CacheHealthIndicator' object has no attribute 'counter'inRuleEngineService(metrics=...). TreatAnyliketype: not injectable, fall back to default. Verified live: 8 cache/rule-engine services that crashed on v26.06.95 now boot clean. ruff + mypy + 346 container/context tests green.