fix(webhooks): subscribe to reconciliation events#497
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
WalkthroughChangesVersioned event publishing
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ListEventPublishers
participant Stack
participant Reconciliation
ListEventPublishers->>Stack: Resolve module version
ListEventPublishers->>Reconciliation: PublishesEvents(version)
Reconciliation-->>ListEventPublishers: Return inclusion decision
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
🛑 Changes requested — automated reviewThe PR introduces a version-gated check in the Reconciliation types to control whether Webhooks subscribes to Reconciliation events. One confirmed issue was found: the semver validity check does not normalize version strings that lack a leading |
NumaryBot
left a comment
There was a problem hiding this comment.
NumaryBot posted 1 new inline finding.
Summary: #497 (comment)
| } | ||
|
|
||
| func IsReconciliationV3(version string) bool { | ||
| return !semver.IsValid(version) || semver.Compare(version, ReconciliationV3Version) >= 0 |
There was a problem hiding this comment.
🟠 [major] Unprefixed semver versions misclassified as non-SemVer/dev
If a stack or Versions entry uses a semver tag without the leading v (e.g. 2.3.1), semver.IsValid returns false and the code falls through to the non-SemVer/dev path, treating it as a development version. This causes Webhooks to subscribe to Reconciliation v2 even though the intent of the gate is to exclude v2. Other version-handling code in the codebase accepts unprefixed semver tags, so this gate is inconsistent and can produce incorrect behavior silently.
Suggestion: Normalize the version string before calling semver.IsValid — e.g. prepend v if it is absent (if !strings.HasPrefix(ver, "v") { ver = "v" + ver }). This ensures unprefixed semver tags are correctly parsed and compared rather than being classified as development/non-SemVer versions.
What changed
v3.0.0-0mainWhy
Reconciliation v3 publishes
reconciliation.alert.*events to its standard message-bus topic. The Operator configured the Reconciliation publisher, but did not expose Reconciliation through the genericEventPublisherdiscovery used to build Webhooks consumers. As a result, Webhooks subscribed only to Ledger and Payments and could never receive Reconciliation events.The version gate is optional so existing publishers such as Ledger, Payments, Orchestration, and TransactionPlane keep their current behavior.
Validation
go fmt ./...go vet ./...CGO_ENABLED=0 go test ./api/formance.com/v1beta1 ./internal/core ./internal/resources/reconciliations ./internal/resources/webhooks ./internal/resources/brokerconsumersThe parallel all-suite run exposed an envtest concurrency flake in
internal/tests; the isolated serial rerun passed all specs.