-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fx.Decorate does not add a missing object to the module #1144
Comments
@abhinav this is the intended design for fx.Decorate. There's a test asserting this behavior also: https://github.com/uber-go/fx/blob/master/decorate_test.go#L471 |
Thinking about it, that probably means we didn't document this behavior properly. Let me fix that. |
Oops, you're right @sywhang. This is intended behavior. |
…graph I created uber-go#1144 because I was not sure whether a decorator could add new values to the graph. This clarifies the behavior. We already have tests to verify this behavior. Resolves uber-go#1144
Describe the bug
If I add an
fx.Decorate
to my module that returns a type that doesn't exist in the container otherwise, the value isn't made available to the module.To Reproduce
Full program
Running this fails with the error:
Expected behavior
The program should run successfully.
Additional context
To get the desired behavior, a placeholder value is needed in the container.
This works, for example:
func main() { fx.New( + fx.Supply(&DBConn{name: "invalid"}), fx.Provide(
Library versions:
I don't think this is intended behavior, but I could be wrong.
The text was updated successfully, but these errors were encountered: