Skip to content

fix(container): Any / Any|None params are not injectable (v26.06.96)#126

Merged
ancongui merged 4 commits into
mainfrom
fix/any-not-injectable
Jun 10, 2026
Merged

fix(container): Any / Any|None params are not injectable (v26.06.96)#126
ancongui merged 4 commits into
mainfrom
fix/any-not-injectable

Conversation

@ancongui

Copy link
Copy Markdown
Contributor

Follow-up to #124/#125. A param typed Any or Any | None was autowired to whatever bean was registered under Any (e.g. an @bean -> Any cache health indicator), injecting the wrong object — 'CacheHealthIndicator' object has no attribute 'counter' in RuleEngineService(metrics=...). Treat Any like type: 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.

ancongui and others added 4 commits June 10, 2026 15:43
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.
@ancongui ancongui merged commit 165ab77 into main Jun 10, 2026
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