-
Notifications
You must be signed in to change notification settings - Fork 0
fix: remove content on unmarshal error #35
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
Conversation
6056c8c to
1a0a27e
Compare
WalkthroughThe changes refactor the payments connector configuration builder by renaming Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/resources/payments_connectors_test.go (1)
105-119: Excellent test coverage for security fix!This test validates that sensitive data (API key) is not leaked in error messages, which directly supports the PR objective.
Consider adding a test case that triggers the credentials unmarshal error path (line 65-67 in payments_connectors.go) to ensure comprehensive coverage of all error paths:
func TestPaymentsCreateConfigFromModel_CredentialsError(t *testing.T) { t.Parallel() plan := PaymentsConnectorsModel{ Credentials: types.DynamicValue(types.StringNull()), Config: types.DynamicValue(NewDynamicObjectValue(map[string]attr.Value{ "provider": types.DynamicValue(types.StringValue("Generic")), }).Value()), } _, err := plan.installConfig(logging.TestingContext()) require.Error(t, err) require.Contains(t, err.Error(), "failed to unmarshal credentials") }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
internal/resources/payments_connectors.go(5 hunks)internal/resources/payments_connectors_test.go(9 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: Dav-14
Repo: formancehq/terraform-provider-stack PR: 30
File: internal/resources/payments_connectors.go:75-83
Timestamp: 2025-10-13T11:09:25.968Z
Learning: In the formancehq/terraform-provider-stack repository, prefer API-side validation over client-side validation in the Terraform provider for payment connector fields like provider, rather than adding validation checks in the Terraform provider code.
🧬 Code graph analysis (1)
internal/resources/payments_connectors_test.go (2)
internal/resources/payments_connectors.go (3)
PaymentsConnectorsModel(53-57)ExtractKeys(22-30)SanitizeUnknownKeys(32-41)internal/resources/helpers.go (1)
NewDynamicObjectValue(16-20)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Tests (E2E)
🔇 Additional comments (5)
internal/resources/payments_connectors.go (3)
59-59: LGTM! Method signature improved.The rename to
installConfigwith context parameter enables proper logging while reducing the public API surface by making the method unexported.
65-91: Good security-focused error handling.The error handling for credentials unmarshal (lines 65-67), marshal (lines 70-73), and config unmarshal (lines 88-90) correctly logs detailed errors to context while returning generic messages. This prevents sensitive data leakage.
222-222: LGTM! Call sites properly updated.Both Create and Update methods correctly invoke
installConfig(ctx)with the context parameter.Also applies to: 325-325
internal/resources/payments_connectors_test.go (2)
1-1: LGTM! Package scope change enables internal testing.Moving from
resources_testtoresourcesallows direct testing of the now-unexportedinstallConfigmethod. This is appropriate for white-box testing of internal behavior.
18-103: LGTM! Tests properly updated for API changes.The existing tests correctly use the new
installConfig(logging.TestingContext())signature and adjust type references for the internal package scope.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #35 +/- ##
==========================================
+ Coverage 55.16% 58.04% +2.87%
==========================================
Files 20 20
Lines 1519 1311 -208
==========================================
- Hits 838 761 -77
+ Misses 566 437 -129
+ Partials 115 113 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.