Skip to content

chore: upgrade deps#102

Merged
gfyrag merged 1 commit into
mainfrom
chore/upgrade-deps
Apr 21, 2026
Merged

chore: upgrade deps#102
gfyrag merged 1 commit into
mainfrom
chore/upgrade-deps

Conversation

@gfyrag
Copy link
Copy Markdown
Contributor

@gfyrag gfyrag commented Apr 20, 2026

No description provided.

@gfyrag gfyrag requested a review from a team as a code owner April 20, 2026 09:11
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

Warning

Rate limit exceeded

@gfyrag has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 33 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 12 minutes and 33 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9fbac656-0539-4749-b60c-75700490d55f

📥 Commits

Reviewing files that changed from the base of the PR and between 759e735 and 534417b.

⛔ Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (41)
  • cmd/root.go
  • cmd/serve.go
  • pkg/api/handler_balances_create_test.go
  • pkg/api/handler_balances_list_test.go
  • pkg/api/handler_holds_confirm.go
  • pkg/api/handler_holds_confirm_test.go
  • pkg/api/handler_holds_get_test.go
  • pkg/api/handler_holds_list_test.go
  • pkg/api/handler_holds_void.go
  • pkg/api/handler_holds_void_test.go
  • pkg/api/handler_transactions_list_test.go
  • pkg/api/handler_wallets_create_test.go
  • pkg/api/handler_wallets_credit.go
  • pkg/api/handler_wallets_credit_test.go
  • pkg/api/handler_wallets_debit.go
  • pkg/api/handler_wallets_debit_test.go
  • pkg/api/handler_wallets_get_test.go
  • pkg/api/handler_wallets_list_test.go
  • pkg/api/handler_wallets_patch.go
  • pkg/api/handler_wallets_patch_test.go
  • pkg/api/handler_wallets_summary_test.go
  • pkg/api/module.go
  • pkg/api/router.go
  • pkg/api/utils.go
  • pkg/api/utils_test.go
  • pkg/balance.go
  • pkg/credit.go
  • pkg/debit.go
  • pkg/hold.go
  • pkg/ledger_interface.go
  • pkg/manager.go
  • pkg/metadata.go
  • pkg/testserver/testserver.go
  • pkg/wallet.go
  • test/e2e/balances_test.go
  • test/e2e/create_test.go
  • test/e2e/credit_test.go
  • test/e2e/debit_test.go
  • test/e2e/suite_test.go
  • test/e2e/summary_test.go
  • test/e2e/transactions_test.go

Walkthrough

This pull request upgrades the project from formancehq/go-libs v3 to v5, reorganizing imports to use pkg/ subdirectories and updating library APIs. Changes span command initialization, API handlers, domain models, and tests, with some functional updates including script value wrapping and FX module changes.

Changes

Cohort / File(s) Summary
CLI & Service Setup
cmd/root.go, cmd/serve.go
Updated service and FX module imports from v3 to v5. Replaced telemetry/auth module registrations (otlp, otlptraces, auth) with new observe/authn FX modules. Changed HTTP client wiring from Provide to Decorate. Updated CLI flag registration for auth and traces.
API Handlers
pkg/api/handler_*.go (non-test)
Updated API imports for idempotency key helpers from v3/api to v5/pkg/transport/api. All handler implementations remain functionally unchanged.
API Routing & Module Setup
pkg/api/router.go, pkg/api/module.go, pkg/api/utils.go
Updated authentication and health module imports. Changed NewRouter parameter type from auth.Authenticator to jwt.Authenticator. Replaced middleware calls from auth.Middleware to jwt.Middleware and service.OTLPMiddleware to httpserver.OTLPMiddleware. Updated cursor type references from bunpaginate to paginate.
API Handler Tests
pkg/api/*_test.go (18 files)
Updated type and pagination imports to v5 equivalents. Added pointer wrapping to script Plain field expectations in multiple test cases. Replaced collection mapping helper from collectionutils.Map to collections.Map. Updated cursor and auth type references.
Core Domain Models
pkg/balance.go, pkg/credit.go, pkg/debit.go, pkg/hold.go, pkg/wallet.go, pkg/metadata.go, pkg/manager.go, pkg/ledger_interface.go
Updated metadata, time, and pointer imports from v3 to v5 pkg/types/ paths. Wrapped transaction script outputs with pointer.For(...) in manager. Changed request field from RequestBody to Query in ledger interface. Updated collection mapping helpers.
Test Infrastructure
pkg/testserver/testserver.go
Updated server URL helper and deferred/testservice imports to v5 equivalents. Function signatures unchanged.
E2E Tests
test/e2e/*.go
Updated logging, pointer, and deferred test framework imports to v5. Modified ledger test server setup to use v4 testservice types with new configuration structure. Updated server URL accessor calls.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 From v3 to v5, we hop with delight,
Reorganizing packages, getting imports just right,
Scripts wrapped in pointers, modules refactored clean,
The biggest library leap this project's ever seen! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess relevance to the changeset. Add a description explaining the dependency upgrade, any breaking changes, and migration rationale to help reviewers understand the scope and impact.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: upgrade deps' accurately describes the changeset, which comprehensively migrates dependencies from go-libs v3 to v5 across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/upgrade-deps

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
pkg/api/handler_balances_create_test.go (1)

51-57: ⚠️ Potential issue | 🟡 Minor

Isolate the expiration validation case.

This case is named with expiration, but wallet.MainBalance is already invalid, so the test can pass without exercising ExpiresAt validation.

🧪 Proposed test fix
 	{
 		name: "with expiration",
 		request: wallet.CreateBalance{
-			Name:      wallet.MainBalance,
+			Name:      uuid.NewString(),
 			ExpiresAt: ptr(time.Now().Add(10 * time.Second)),
 		},
 		expectedStatusCode: http.StatusBadRequest,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/api/handler_balances_create_test.go` around lines 51 - 57, The test case
"with expiration" is not isolating expiration validation because it uses
wallet.MainBalance (already invalid); update the test to use a valid balance
name (e.g., a non-reserved name or the same valid value used in other passing
cases) in the wallet.CreateBalance payload, keep ExpiresAt set to
ptr(time.Now().Add(10 * time.Second)), and assert the expectedStatusCode and
expectedErrorCode still reflect the expiration validation failure; adjust only
the Name field in that case so the test exercises ExpiresAt validation rather
than failing on wallet.MainBalance.
cmd/serve.go (1)

45-68: ⚠️ Potential issue | 🔴 Critical

Change fx.Decorate to fx.Provide for *http.Client; no upstream provider exists.

fx.Decorate requires an existing provider to wrap. Here, nothing in the options array provides *http.Client — neither observefx, authnfx, nor service.New(). The decorator will be silently ignored by Fx, and when wallet.Module's DefaultLedger tries to resolve its *http.Client dependency at startup, Fx will fail with a "missing dependencies" error.

Since GetHTTPClient() takes no parameter and returns *http.Client, this should be fx.Provide(...) instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/serve.go` around lines 45 - 68, The code uses fx.Decorate to register
GetHTTPClient which provides *http.Client but fx.Decorate expects an existing
provider to wrap, so replace the fx.Decorate(...) call that wraps GetHTTPClient
with fx.Provide(...) so Fx actually registers the *http.Client provider; update
the options array where GetHTTPClient is currently passed into fx.Decorate
(referencing GetHTTPClient, fx.Decorate, fx.Provide, wallet.Module and
DefaultLedger) to use fx.Provide with the same function arguments so
wallet.Module's *http.Client dependency resolves at startup.
🧹 Nitpick comments (3)
pkg/api/handler_balances_list_test.go (1)

11-15: Misleading sharedapi alias — it now points to the paginate package.

In pkg/api/utils.go, sharedapi aliases github.com/formancehq/go-libs/v5/pkg/transport/api while paginate is imported separately for paginate.Cursor[T]. Here sharedapi is aliased to the paginate package itself, so subsequent sharedapi.Cursor[...] usages actually reference paginate.Cursor. Works, but the alias is confusing and inconsistent with the production file. Consider renaming the alias to paginate (or dropping the alias entirely) for consistency.

♻️ Suggested alias rename
-	sharedapi "github.com/formancehq/go-libs/v5/pkg/storage/bun/paginate"
+	"github.com/formancehq/go-libs/v5/pkg/storage/bun/paginate"

Then replace sharedapi.Cursor[...] with paginate.Cursor[...] throughout the file.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/api/handler_balances_list_test.go` around lines 11 - 15, The test import
alias `sharedapi` incorrectly points to the `paginate` package making
`sharedapi.Cursor[...]` refer to `paginate.Cursor`; change the import alias to
`paginate` (or remove the alias) in the import block and then replace all
occurrences of `sharedapi.Cursor[...]` with `paginate.Cursor[...]` so the alias
matches production usage; ensure any other references to `sharedapi` in this
file are updated or left pointing to the transport/api package if needed.
pkg/api/handler_transactions_list_test.go (1)

12-19: Consider extracting the repeated transaction mapper.

The migration itself looks good. If this test gets touched again, a small helper would avoid keeping the two identical shared.V2Transaction mapping blocks in sync.

♻️ Optional refactor
+	mapTransaction := func(from shared.V2Transaction) shared.V2Transaction {
+		return shared.V2Transaction{
+			ID:                from.ID,
+			Metadata:          from.Metadata,
+			PostCommitVolumes: nil,
+			Postings:          from.Postings,
+			PreCommitVolumes:  nil,
+			Reference:         from.Reference,
+			Reverted:          from.Reverted,
+			Timestamp:         from.Timestamp,
+		}
+	}
+
 	var testEnv *testEnv
 	testEnv = newTestEnv(
 		WithListTransactions(func(ctx context.Context, ledger string, query wallet.ListTransactionsQuery) (*shared.V2TransactionsCursorResponseCursor, error) {
@@
-					Data: collections.Map(transactions[page*pageSize:(page+1)*pageSize], func(from shared.V2Transaction) shared.V2Transaction {
-						return shared.V2Transaction{
-							ID:                from.ID,
-							Metadata:          from.Metadata,
-							PostCommitVolumes: nil,
-							Postings:          from.Postings,
-							PreCommitVolumes:  nil,
-							Reference:         from.Reference,
-							Reverted:          from.Reverted,
-							Timestamp:         from.Timestamp,
-						}
-					}),
+					Data: collections.Map(transactions[page*pageSize:(page+1)*pageSize], mapTransaction),
@@
-				Data: collections.Map(transactions[:pageSize], func(from shared.V2Transaction) shared.V2Transaction {
-					return shared.V2Transaction{
-						ID:                from.ID,
-						Metadata:          from.Metadata,
-						PostCommitVolumes: nil,
-						Postings:          from.Postings,
-						PreCommitVolumes:  nil,
-						Reference:         from.Reference,
-						Reverted:          from.Reverted,
-						Timestamp:         from.Timestamp,
-					}
-				}),
+				Data: collections.Map(transactions[:pageSize], mapTransaction),

Also applies to: 66-77, 89-100

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/api/handler_transactions_list_test.go` around lines 12 - 19, Two
identical shared.V2Transaction mapping blocks are duplicated in the test;
extract them into a single helper to avoid drift. Create a small helper function
(e.g., makeV2Transaction or mapToV2Transaction) that returns a
shared.V2Transaction built from the same inputs used in the two blocks, update
both places (the two shared.V2Transaction construction sites currently
duplicated) to call that helper, and keep any field initialization or
pointer/metadata handling centralized in that helper so the test uses the single
source of truth.
cmd/serve.go (1)

88-104: Pre-existing: instrumented transport is bypassed for API calls.

Not introduced by this PR, but worth noting while touching this code: when clientID != "", clientCredentialsConfig.Client(...) returns a client whose Transport is oauth2.Transport{Base: nil}, which defaults to http.DefaultTransport. The oauth2.HTTPClient context value is used only for token fetching. As a result, observe.NewRoundTripper instrumentation applies only to token fetches, not to ledger API calls made through this client.

If full request-path tracing is desired, set Base on the returned transport (or wrap the returned client's Transport) to the instrumented one.

Proposed fix
-	return clientCredentialsConfig.Client(context.WithValue(ctx, oauth2.HTTPClient, httpClient)), nil
+	oauthClient := clientCredentialsConfig.Client(context.WithValue(ctx, oauth2.HTTPClient, httpClient))
+	if t, ok := oauthClient.Transport.(*oauth2.Transport); ok {
+		t.Base = httpClient.Transport
+	}
+	return oauthClient, nil
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/serve.go` around lines 88 - 104, GetHTTPClient currently creates an
instrumented transport via observe.NewRoundTripper but when clientID != "" it
returns clientcredentials.Config.Client(...) whose oauth2.Transport has
Base==nil so API calls bypass instrumentation; modify GetHTTPClient so after
calling clientCredentialsConfig.Client(...) you set/ensure the returned client's
Transport uses the instrumented transport (either by setting
returnedClient.Transport.(*oauth2.Transport).Base =
observe.NewRoundTripper(http.DefaultTransport, debug) or by wrapping/assigning
returnedClient.Transport = observe.NewRoundTripper(returnedClient.Transport,
debug)) so both token fetches and ledger API calls go through the instrumented
roundtripper.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@cmd/serve.go`:
- Around line 45-68: The code uses fx.Decorate to register GetHTTPClient which
provides *http.Client but fx.Decorate expects an existing provider to wrap, so
replace the fx.Decorate(...) call that wraps GetHTTPClient with fx.Provide(...)
so Fx actually registers the *http.Client provider; update the options array
where GetHTTPClient is currently passed into fx.Decorate (referencing
GetHTTPClient, fx.Decorate, fx.Provide, wallet.Module and DefaultLedger) to use
fx.Provide with the same function arguments so wallet.Module's *http.Client
dependency resolves at startup.

In `@pkg/api/handler_balances_create_test.go`:
- Around line 51-57: The test case "with expiration" is not isolating expiration
validation because it uses wallet.MainBalance (already invalid); update the test
to use a valid balance name (e.g., a non-reserved name or the same valid value
used in other passing cases) in the wallet.CreateBalance payload, keep ExpiresAt
set to ptr(time.Now().Add(10 * time.Second)), and assert the expectedStatusCode
and expectedErrorCode still reflect the expiration validation failure; adjust
only the Name field in that case so the test exercises ExpiresAt validation
rather than failing on wallet.MainBalance.

---

Nitpick comments:
In `@cmd/serve.go`:
- Around line 88-104: GetHTTPClient currently creates an instrumented transport
via observe.NewRoundTripper but when clientID != "" it returns
clientcredentials.Config.Client(...) whose oauth2.Transport has Base==nil so API
calls bypass instrumentation; modify GetHTTPClient so after calling
clientCredentialsConfig.Client(...) you set/ensure the returned client's
Transport uses the instrumented transport (either by setting
returnedClient.Transport.(*oauth2.Transport).Base =
observe.NewRoundTripper(http.DefaultTransport, debug) or by wrapping/assigning
returnedClient.Transport = observe.NewRoundTripper(returnedClient.Transport,
debug)) so both token fetches and ledger API calls go through the instrumented
roundtripper.

In `@pkg/api/handler_balances_list_test.go`:
- Around line 11-15: The test import alias `sharedapi` incorrectly points to the
`paginate` package making `sharedapi.Cursor[...]` refer to `paginate.Cursor`;
change the import alias to `paginate` (or remove the alias) in the import block
and then replace all occurrences of `sharedapi.Cursor[...]` with
`paginate.Cursor[...]` so the alias matches production usage; ensure any other
references to `sharedapi` in this file are updated or left pointing to the
transport/api package if needed.

In `@pkg/api/handler_transactions_list_test.go`:
- Around line 12-19: Two identical shared.V2Transaction mapping blocks are
duplicated in the test; extract them into a single helper to avoid drift. Create
a small helper function (e.g., makeV2Transaction or mapToV2Transaction) that
returns a shared.V2Transaction built from the same inputs used in the two
blocks, update both places (the two shared.V2Transaction construction sites
currently duplicated) to call that helper, and keep any field initialization or
pointer/metadata handling centralized in that helper so the test uses the single
source of truth.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 85d0ee6a-5a38-4079-96ad-e0e4c61e6986

📥 Commits

Reviewing files that changed from the base of the PR and between a3070d0 and 759e735.

⛔ Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (41)
  • cmd/root.go
  • cmd/serve.go
  • pkg/api/handler_balances_create_test.go
  • pkg/api/handler_balances_list_test.go
  • pkg/api/handler_holds_confirm.go
  • pkg/api/handler_holds_confirm_test.go
  • pkg/api/handler_holds_get_test.go
  • pkg/api/handler_holds_list_test.go
  • pkg/api/handler_holds_void.go
  • pkg/api/handler_holds_void_test.go
  • pkg/api/handler_transactions_list_test.go
  • pkg/api/handler_wallets_create_test.go
  • pkg/api/handler_wallets_credit.go
  • pkg/api/handler_wallets_credit_test.go
  • pkg/api/handler_wallets_debit.go
  • pkg/api/handler_wallets_debit_test.go
  • pkg/api/handler_wallets_get_test.go
  • pkg/api/handler_wallets_list_test.go
  • pkg/api/handler_wallets_patch.go
  • pkg/api/handler_wallets_patch_test.go
  • pkg/api/handler_wallets_summary_test.go
  • pkg/api/module.go
  • pkg/api/router.go
  • pkg/api/utils.go
  • pkg/api/utils_test.go
  • pkg/balance.go
  • pkg/credit.go
  • pkg/debit.go
  • pkg/hold.go
  • pkg/ledger_interface.go
  • pkg/manager.go
  • pkg/metadata.go
  • pkg/testserver/testserver.go
  • pkg/wallet.go
  • test/e2e/balances_test.go
  • test/e2e/create_test.go
  • test/e2e/credit_test.go
  • test/e2e/debit_test.go
  • test/e2e/suite_test.go
  • test/e2e/summary_test.go
  • test/e2e/transactions_test.go

@gfyrag gfyrag force-pushed the chore/upgrade-deps branch from 759e735 to 534417b Compare April 20, 2026 12:57
@gfyrag gfyrag merged commit 2f82c43 into main Apr 21, 2026
6 checks passed
@gfyrag gfyrag deleted the chore/upgrade-deps branch April 21, 2026 08:56
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.

2 participants