InternalProvisionException.errorInUserCode discards important context about user errors
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
There is a special case in InternalProvisionException.errorInUserCode https://github.com/google/guice/blob/e960b66d3d5931b9cb1aebd49e452e2c489a921e/core/src/com/google/inject/internal/InternalProvisionException.java#L91-L102
which has been pre-flagged as TODO by the author of the function (see git blame https://github.com/google/guice/blame/e960b66d3d5931b9cb1aebd49e452e2c489a921e/core/src/com/google/inject/internal/InternalProvisionException.java#L95) as a potential problem, and I was just hit by this - it indeed discard important context!
What was happening is there was:
- guice's provider of ClassA .get being called,
- instantiating the actual custom provider ClassAProvider, then calling its .get
- doing a lot of work, part of it (4 stack frame bellow) is happening in ClassX, doing injector.getInstance for ClassB -> this fails with ConfigurationError
- the ConfigurationError (with the relevant stacktrace) is discarded in .errorInUserCode, only its message is kept.
What did I observe?
A ProvisionException that talks about failing to provision ClassB, while provisioning ClassA via ClassAProvider. If you look into ClassAProvider construtor, you don't see any ties to ClassB. It does not mention that code of ClassX in anyway in the text or stacktrace.
You have to start debugging ClassAProvider / Guice itself to find out where is the nested Guice error happening / being discarded.
Contributor guide
Assessment
This issue has not been assessed yet.