Skip to content

Conversation

Quentin-David-24
Copy link
Contributor

Adds compatibility for Connectivity V3 module and Adyen connector.

@Quentin-David-24 Quentin-David-24 requested a review from a team as a code owner August 19, 2025 14:07
Copy link
Contributor

coderabbitai bot commented Aug 19, 2025

Walkthrough

Adds version-aware Adyen connector installation: introduces PaymentsVersion and SetVersion, resolves payments version at runtime, reads the script once, and dispatches to V3 or legacy (V0/V1/V2) install flows with appropriate request types and response handling.

Changes

Cohort / File(s) Summary of Changes
Adyen connector install versioning
cmd/payments/connectors/install/adyen.go
Added PaymentsVersion field and SetVersion method; import versions; refactored Run to call versions.GetPaymentsVersion, read script once, unmarshal into either shared.V3AdyenConfig (V3) or shared.AdyenConfig (V0/V1/V2), and invoke Payments.V3.InstallConnector or Payments.V1.InstallConnector accordingly; preserve error handling and connector ID storage.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant CLI as fctl CLI
  participant Ver as versions.GetPaymentsVersion
  participant APIv3 as Payments.V3
  participant APIv1 as Payments.V1
  participant Store as store

  User->>CLI: fctl payments connectors install adyen
  CLI->>Ver: GetPaymentsVersion(cmd,args,c)
  CLI->>CLI: Read script
  alt Version == V3
    CLI->>CLI: Unmarshal -> shared.V3AdyenConfig
    CLI->>APIv3: InstallConnector(V3InstallConnectorRequest)
    alt 2xx
      APIv3-->>CLI: V3InstallConnectorResponse
      CLI->>Store: set Success, Connector, ConnectorID
    else error
      APIv3-->>CLI: Error
      CLI->>User: Report error
    end
  else V0/V1/V2
    CLI->>CLI: Unmarshal -> shared.AdyenConfig
    CLI->>APIv1: InstallConnector(InstallConnectorRequest)
    alt 2xx
      APIv1-->>CLI: ConnectorResponse
      CLI->>Store: set Success, Connector, ConnectorID
    else error
      APIv1-->>CLI: Error
      CLI->>User: Report error
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
Use V3 endpoints for payments connectivity when applicable (FCTL-9)
Support correct config schema for V3 vs legacy during installation (FCTL-9)
Preserve legacy path for non-V3 versions (FCTL-9)

Assessment against linked issues: Out-of-scope changes

None found.

Poem

I nibble at versions, hop through the stack,
V3 or V1 — I always keep track.
Scripts read once, installs proceed fine,
Connector IDs tucked in a neat little line.
A rabbit's small dance — the deploy looks divine. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/FCTL-9-adyen-v3

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
cmd/payments/connectors/install/adyen.go (2)

83-90: Verify connector identifier casing for V3 path; prefer constants for consistency

You set both Type and Connector to "Adyen". API/SDKs often require a specific casing or enum for these values. To avoid subtle 400s, prefer constants where available and keep the path param consistent with other commands (internal.AdyenConnector is "adyen").

Proposed minimal change for the path parameter (leave Type as-is unless a proper enum exists in shared):

-        response, err := store.Client().Payments.V3.InstallConnector(cmd.Context(), operations.V3InstallConnectorRequest{
+        response, err := store.Client().Payments.V3.InstallConnector(cmd.Context(), operations.V3InstallConnectorRequest{
             V3InstallConnectorRequest: &shared.V3InstallConnectorRequest{
                 V3AdyenConfig: &config,
                 Type:          "Adyen",
             },
-            Connector: "Adyen",
+            Connector: internal.AdyenConnector,
         })

Please also check if shared has a typed enum for V3 connector Type (e.g., shared.ConnectorTypeAdyen). If so, use it instead of the raw string.


101-103: Defensive nil-check on V3 response before accessing data

If V3InstallConnectorResponse is nil, calling GetData() could risk a panic depending on the codegen. A small guard is safer.

-        if response.V3InstallConnectorResponse.GetData() != "" {
-            c.store.ConnectorID = response.V3InstallConnectorResponse.GetData()
-        }
+        if response.V3InstallConnectorResponse != nil {
+            if id := response.V3InstallConnectorResponse.GetData(); id != "" {
+                c.store.ConnectorID = id
+            }
+        }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0e06695 and 9e0ccfb.

📒 Files selected for processing (1)
  • cmd/payments/connectors/install/adyen.go (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
cmd/payments/connectors/install/adyen.go (2)
cmd/payments/versions/versions.go (5)
  • GetPaymentsVersion (24-52)
  • V3 (17-17)
  • V0 (14-14)
  • V2 (16-16)
  • V1 (15-15)
cmd/payments/connectors/internal/connectors.go (1)
  • AdyenConnector (4-4)
🪛 GitHub Actions: Default
cmd/payments/connectors/install/adyen.go

[error] 3-8: Unstaged changes detected in repository: modified file cmd/payments/connectors/install/adyen.go. Commit or stash changes to continue.

🔇 Additional comments (6)
cmd/payments/connectors/install/adyen.go (6)

6-6: Importing versions package — LGTM

This aligns with the new version-aware install flow.


24-31: Controller version state and setter — LGTM

Adding PaymentsVersion and SetVersion cleanly implements the versions.VersionController contract.


67-70: Runtime selection of payments version — LGTM

This ensures the install path matches the server’s version instead of defaulting to V1.


71-75: Read script once and reuse — LGTM

Avoids duplicate I/O across version branches.


113-118: Legacy (V0/V1/V2) request payload — LGTM

Correct usage of ConnectorConfig.AdyenConfig and shared.ConnectorAdyen.


1-1: Configure Git identity and commit changes

It looks like CI is still failing due to unstaged modifications in cmd/payments/connectors/install/adyen.go, but your local git commit failed because your user identity isn’t configured. Please:

  • Set your git name and email:
    git config --global user.name "Your Name"
    git config --global user.email "[email protected]"
    
  • Stage and commit the file:
    git add cmd/payments/connectors/install/adyen.go
    git commit -m "fix: adyen v3 install flow and version routing"
    
  • Push your branch and rerun CI to confirm the issue is resolved.

Comment on lines 105 to 132
case versions.V0:
case versions.V2:
case versions.V1:
var config shared.AdyenConfig
if err := json.Unmarshal([]byte(script), &config); err != nil {
return nil, err
}

response, err := store.Client().Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{
ConnectorConfig: shared.ConnectorConfig{
AdyenConfig: &config,
},
Connector: shared.ConnectorAdyen,
})
if err != nil {
return nil, errors.Wrap(err, "installing connector")
}
if response.StatusCode >= 300 {
return nil, fmt.Errorf("unexpected status code: %d", response.StatusCode)
}

c.store.Success = true
c.store.ConnectorName = internal.AdyenConnector

if response.ConnectorResponse != nil {
c.store.ConnectorID = response.ConnectorResponse.Data.ConnectorID
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Bug: V0 and V2 cases do nothing (no implicit fallthrough in Go)

In Go, switch cases don’t fall through by default. As written, versions.V0 and versions.V2 will execute no code and silently skip installation. Combine cases and add a default to future-proof.

Apply this diff to group legacy versions and add a default branch:

@@
-    case versions.V0:
-    case versions.V2:
-    case versions.V1:
+    case versions.V0, versions.V2, versions.V1:
         var config shared.AdyenConfig
         if err := json.Unmarshal([]byte(script), &config); err != nil {
             return nil, err
         }
 
         response, err := store.Client().Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{
             ConnectorConfig: shared.ConnectorConfig{
                 AdyenConfig: &config,
             },
             Connector: shared.ConnectorAdyen,
         })
         if err != nil {
             return nil, errors.Wrap(err, "installing connector")
         }
         if response.StatusCode >= 300 {
             return nil, fmt.Errorf("unexpected status code: %d", response.StatusCode)
         }
 
         c.store.Success = true
         c.store.ConnectorName = internal.AdyenConnector
 
         if response.ConnectorResponse != nil {
             c.store.ConnectorID = response.ConnectorResponse.Data.ConnectorID
         }
+    default:
+        return nil, fmt.Errorf("unsupported payments version: %d", c.PaymentsVersion)
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case versions.V0:
case versions.V2:
case versions.V1:
var config shared.AdyenConfig
if err := json.Unmarshal([]byte(script), &config); err != nil {
return nil, err
}
response, err := store.Client().Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{
ConnectorConfig: shared.ConnectorConfig{
AdyenConfig: &config,
},
Connector: shared.ConnectorAdyen,
})
if err != nil {
return nil, errors.Wrap(err, "installing connector")
}
if response.StatusCode >= 300 {
return nil, fmt.Errorf("unexpected status code: %d", response.StatusCode)
}
c.store.Success = true
c.store.ConnectorName = internal.AdyenConnector
if response.ConnectorResponse != nil {
c.store.ConnectorID = response.ConnectorResponse.Data.ConnectorID
}
}
case versions.V0, versions.V2, versions.V1:
var config shared.AdyenConfig
if err := json.Unmarshal([]byte(script), &config); err != nil {
return nil, err
}
response, err := store.Client().Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{
ConnectorConfig: shared.ConnectorConfig{
AdyenConfig: &config,
},
Connector: shared.ConnectorAdyen,
})
if err != nil {
return nil, errors.Wrap(err, "installing connector")
}
if response.StatusCode >= 300 {
return nil, fmt.Errorf("unexpected status code: %d", response.StatusCode)
}
c.store.Success = true
c.store.ConnectorName = internal.AdyenConnector
if response.ConnectorResponse != nil {
c.store.ConnectorID = response.ConnectorResponse.Data.ConnectorID
}
default:
return nil, fmt.Errorf("unsupported payments version: %d", c.PaymentsVersion)
}
🤖 Prompt for AI Agents
In cmd/payments/connectors/install/adyen.go around lines 105 to 132, the switch
handles versions.V0 and versions.V2 as empty cases so they do nothing because Go
cases don't fall through; combine the cases so V0, V1 and V2 execute the same
installation logic (e.g., case versions.V0, versions.V1, versions.V2:) and
remove empty branches, and add a default branch that returns a clear error for
unsupported/unknown versions to future-proof the code.

@Quentin-David-24 Quentin-David-24 changed the title fix/FCTL-9-adyen-v3-install fix: Adyen installation with V3 Aug 19, 2025
Copy link
Contributor

@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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
cmd/payments/connectors/install/adyen.go (1)

106-130: Legacy versions grouped correctly.

Thanks for addressing the earlier fallthrough issue by combining V0/V1/V2 into one branch.

🧹 Nitpick comments (4)
cmd/payments/connectors/install/adyen.go (4)

25-26: Consider making PaymentsVersion unexported.

Unless external packages must mutate it directly, prefer an unexported field (e.g., paymentsVersion) and keep SetVersion as the mutation point.


77-131: Add a default branch for future-proofing unsupported versions.

Your switch covers V0/V1/V2 and V3. A default branch will fail fast if a new enum value is introduced.

Apply this diff to add a default case:

 switch c.PaymentsVersion {
 case versions.V3:
   ...
 case versions.V0, versions.V1, versions.V2:
   ...
-  }
+  default:
+    return nil, fmt.Errorf("unsupported payments version: %d", c.PaymentsVersion)
+  }

80-83: Wrap unmarshal error with context (V3).

Adds clarity to user-facing errors when the provided config JSON is invalid.

Apply this diff:

-        if err := json.Unmarshal([]byte(script), &config); err != nil {
-            return nil, err
-        }
+        if err := json.Unmarshal([]byte(script), &config); err != nil {
+            return nil, errors.Wrap(err, "invalid V3 Adyen config")
+        }

108-111: Wrap unmarshal error with context (legacy V0/V1/V2).

Improves diagnostics for configuration parse failures.

Apply this diff:

-        if err := json.Unmarshal([]byte(script), &config); err != nil {
-            return nil, err
-        }
+        if err := json.Unmarshal([]byte(script), &config); err != nil {
+            return nil, errors.Wrap(err, "invalid legacy Adyen config")
+        }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9e0ccfb and b2198b1.

📒 Files selected for processing (1)
  • cmd/payments/connectors/install/adyen.go (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
cmd/payments/connectors/install/adyen.go (2)
cmd/payments/versions/versions.go (5)
  • GetPaymentsVersion (24-52)
  • V3 (17-17)
  • V0 (14-14)
  • V1 (15-15)
  • V2 (16-16)
cmd/payments/connectors/internal/connectors.go (1)
  • AdyenConnector (4-4)
🔇 Additional comments (4)
cmd/payments/connectors/install/adyen.go (4)

7-8: Importing versions package is appropriate.

Needed for runtime version resolution; no issues.


30-33: SetVersion implementation looks good.

Meets the VersionController contract and keeps the versioning concern isolated in the controller.


68-71: Resolving payments version before dispatch is correct.

Good call to derive version once and use it to route the install flow.


72-75: Reading the script once is the right refactor.

Avoids duplicate IO across version branches.

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.

1 participant