fix: serve crash with --publisher-http-enabled (TS-456)#1418
Conversation
go-libs v5.3.2's authnfx.JWTModule (loaded unconditionally by serve) and
messagingfx.HTTPModule both supply an unnamed *http.Client at the parent
fx scope. uber/fx rejects the duplicate provider, so ledger serve
crashes at startup with:
cannot provide *http.Client from [0]: already provided by "reflect".makeFuncStub
Pull in the go-libs fix (formancehq/go-libs#651) via a `replace`
directive on a v5.3.2-based commit of the fix. Drop the replace and
bump to v5.3.3 (or v5.4.x) once tagged.
Adds an e2e regression test that boots ledger serve with
--publisher-http-enabled and asserts startup succeeds. Fails on
release/v2.4 head with the exact error above; passes with this fix.
Refs: TS-456
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (6)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughA new end-to-end Ginkgo regression test is added in ChangesPublisher HTTP startup regression test
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
NumaryBot
left a comment
There was a problem hiding this comment.
✅ Approve — automated review
No discrete correctness issues were identified in the dependency replacement or the added regression test based on the diff.
No findings.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/v2.4 #1418 +/- ##
================================================
- Coverage 81.21% 81.19% -0.03%
================================================
Files 206 206
Lines 11250 11259 +9
================================================
+ Hits 9137 9142 +5
- Misses 1561 1566 +5
+ Partials 552 551 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
go-libs#651 is merged and v5.5.0 is tagged. Drop the temporary `replace` directive and bump to the released version.
|
go-libs#651 merged + tagged as v5.5.0. |
NumaryBot
left a comment
There was a problem hiding this comment.
✅ Approve — automated review
No concrete correctness issues were identified in the dependency bump or the added regression test based on the checked-out diff.
No findings.
NumaryBot
left a comment
There was a problem hiding this comment.
✅ Approve — automated review
The dependency bump and regression test align with the reported fx provider conflict, and no discrete introduced correctness issue is evident from the diff.
No findings.
NumaryBot
left a comment
There was a problem hiding this comment.
✅ Approve — automated review
The dependency bump brings in the fx scoping fix and the added e2e regression test exercises the reported startup path. I did not find a discrete regression introduced by these changes.
No findings.
Summary
ledger serve(>= v2.3.3, including all v2.4.x) crashes at startup whenever--publisher-http-enabled(orPUBLISHER_HTTP_ENABLED=true) is set, with the error `cannot provide *http.Client from [0]: already provided by "reflect".makeFuncStub`.cmd.NewServeCommandloadsauthnfx.JWTModuleFromFlagsunconditionally (which always supplies a*http.Client).messagingfx.HTTPModulesupplies another one as soon as the HTTP publisher is enabled, and uber/fx rejects the duplicate.main). This PR pulls it in via areplacedirective on a v5.3.2-based cherry-pick of the fix commit, so the only diff vsv5.3.2is the scoping change itself.test/e2e/app_publisher_http_jwt_test.go) that boots ledger with--publisher-http-enabledand asserts startup succeeds.Follow-up (before / after merge)
v5.3.3(orv5.4.1) on go-libs.replacedirective ingo.modwith a regular bump to the released version.The
// TS-456comment ingo.modis there to make this hand-off obvious.Customer impact
Reported by Mews on TS-456. The exact repro from the ticket:
```sh
docker run --rm -e DEBUG=true \
-e POSTGRES_URI='postgresql://x:x@127.0.0.1/x?sslmode=disable' \
-e PUBLISHER_HTTP_ENABLED=true \
-e PUBLISHER_TOPIC_MAPPING='*:http://example:8080' \
ghcr.io/formancehq/ledger:v2.4.10 serve
```
Test plan
test/e2e/app_publisher_http_jwt_test.go(-tags=it) fails onrelease/v2.4head with the exact provider-conflict error.replacedirective applied.go build ./...clean.replaceforrequire v5.3.3once go-libs releases.Related PRs