Skip to content
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

fix(*): fix release and v2 handlers #221

Merged
merged 3 commits into from
Dec 18, 2024
Merged

fix(*): fix release and v2 handlers #221

merged 3 commits into from
Dec 18, 2024

Conversation

paul-nicolas
Copy link
Contributor

@paul-nicolas paul-nicolas commented Dec 18, 2024

Multiple fixes:

  • Since gorelease is not using earthly, we need
    to have the list.go already filled before releasing.
    I added it in the lint/pre-commit method on earthly,
    so that the CI fails if not up to date.
  • Remove a useless temporal search attributes
  • Do the right translation of connectors for v2
  • Do the right translation for payment scheme for v2

Copy link
Contributor

coderabbitai bot commented Dec 18, 2024

Walkthrough

The pull request introduces comprehensive modifications across multiple files in the FormanceHQ payments project. The changes primarily focus on enhancing provider and payment scheme handling, standardizing connector and payment method representations, and updating import mechanisms for payment plugins. Key modifications include the introduction of new utility functions for provider and scheme transformations, the addition of constants for various payment connectors and schemes, and updates to the Earthfile for build, test, and deployment processes.

Changes

File Change Summary
Earthfile Updated build and deployment processes, refined test execution logic, added new tag generation mechanism
internal/api/v2/handler_* files Introduced toV2Provider and toV2PaymentScheme functions for consistent provider and scheme handling across multiple handlers
internal/api/v2/utils.go Added constants for payment connectors and schemes, implemented transformation functions
internal/connectors/engine/search_attributes.go Removed workflow.SearchAttributeWorkflowID mapping
internal/connectors/engine/workflow/workflow.go Removed SearchAttributeWorkflowID constant
internal/connectors/plugins/public/list.go Added side-loaded imports for various payment connector plugins

Sequence Diagram

sequenceDiagram
    participant Client
    participant APIHandler
    participant UtilityFunctions
    participant Backend

    Client->>APIHandler: Send Request
    APIHandler->>UtilityFunctions: Transform Provider
    UtilityFunctions-->>APIHandler: Processed Provider
    APIHandler->>UtilityFunctions: Transform Payment Scheme
    UtilityFunctions-->>APIHandler: Processed Scheme
    APIHandler->>Backend: Process Request
    Backend-->>APIHandler: Return Response
    APIHandler-->>Client: Send Response
Loading

Poem

🐰 Hop, hop, through the code we go,
Providers transformed, schemes in a row,
Connectors dancing, plugins so bright,
Payments flowing with technical might!
A rabbit's refactor, clean and so neat! 🚀


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9ee2716 and 57d23fd.

⛔ Files ignored due to path filters (1)
  • internal/connectors/plugins/configs.json is excluded by !**/*.json
📒 Files selected for processing (1)
  • Earthfile (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Earthfile

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

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

@paul-nicolas paul-nicolas force-pushed the fix/release branch 2 times, most recently from d16c439 to 89bbec5 Compare December 18, 2024 07:02
Multiple fixes:
- Since gorelease is not using earthly, we need
to have the list.go already filled before releasing.
I added it in the lint/pre-commit method on earthly,
so that the CI fails if not up to date.
- Remove a useless temporal search attributes
- Do the right translation of connectors for v2
- Do the right translation for payment scheme for v2
@paul-nicolas paul-nicolas marked this pull request as ready for review December 18, 2024 07:24
@paul-nicolas paul-nicolas requested a review from a team as a code owner December 18, 2024 07:24
@paul-nicolas paul-nicolas changed the title fix(release): fix missing files and init fix(*): fix release and v2 handlers Dec 18, 2024
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 (3)
internal/api/v2/handler_bank_accounts_get.go (1)

Line range hint 20-63: Consider documenting the V2/V3 provider transformation strategy

The codebase shows a pattern of V2/V3 provider transformations across multiple handlers. This suggests either:

  1. A transition between API versions
  2. A need to maintain compatibility between different provider formats

Consider:

  1. Documenting the transformation strategy
  2. Adding version compatibility tests
  3. Planning for eventual deprecation of older versions if applicable
internal/api/v2/handler_connectors_list.go (1)

Line range hint 39-42: Consider pagination improvements in next API version.

The current implementation fetches all records (pageSize: 1000) to maintain backward compatibility. Consider adding proper pagination support in the next API version for better scalability.

internal/api/v2/handler_bank_accounts_list.go (1)

Line range hint 21-31: Consider extracting pagination logic.

The pagination extraction and error handling logic could be moved to a shared utility function to improve code reusability across handlers.

+func extractPagination[T any](span trace.Span, r *http.Request, query T) (*storage.ListBankAccountsQuery, error) {
+    options, err := getPagination(span, r, query)
+    if err != nil {
+        otel.RecordError(span, err)
+        return nil, err
+    }
+    return pointer.For(storage.NewListBankAccountsQuery(*options)), nil
+}
+
 func bankAccountsList(backend backend.Backend) http.HandlerFunc {
     return func(w http.ResponseWriter, r *http.Request) {
         ctx, span := otel.Tracer().Start(r.Context(), "v2_bankAccountsList")
         defer span.End()
 
-        query, err := bunpaginate.Extract[storage.ListBankAccountsQuery](r, func() (*storage.ListBankAccountsQuery, error) {
-            options, err := getPagination(span, r, storage.BankAccountQuery{})
-            if err != nil {
-                otel.RecordError(span, err)
-                return nil, err
-            }
-            return pointer.For(storage.NewListBankAccountsQuery(*options)), nil
-        })
+        query, err := bunpaginate.Extract[storage.ListBankAccountsQuery](r, 
+            func() (*storage.ListBankAccountsQuery, error) {
+                return extractPagination(span, r, storage.BankAccountQuery{})
+            })
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c54d2c1 and 7407d8f.

📒 Files selected for processing (15)
  • Earthfile (1 hunks)
  • internal/api/v2/handler_accounts_get.go (1 hunks)
  • internal/api/v2/handler_accounts_list.go (1 hunks)
  • internal/api/v2/handler_bank_accounts_get.go (1 hunks)
  • internal/api/v2/handler_bank_accounts_list.go (1 hunks)
  • internal/api/v2/handler_connectors_install.go (1 hunks)
  • internal/api/v2/handler_connectors_list.go (1 hunks)
  • internal/api/v2/handler_payments_create.go (1 hunks)
  • internal/api/v2/handler_payments_get.go (1 hunks)
  • internal/api/v2/handler_payments_list.go (1 hunks)
  • internal/api/v2/handler_transfer_initiations_get.go (1 hunks)
  • internal/api/v2/utils.go (2 hunks)
  • internal/connectors/engine/search_attributes.go (0 hunks)
  • internal/connectors/engine/workflow/workflow.go (0 hunks)
  • internal/connectors/plugins/public/list.go (1 hunks)
💤 Files with no reviewable changes (2)
  • internal/connectors/engine/search_attributes.go
  • internal/connectors/engine/workflow/workflow.go
✅ Files skipped from review due to trivial changes (1)
  • internal/connectors/plugins/public/list.go
🔇 Additional comments (13)
internal/api/v2/handler_connectors_install.go (1)

20-22: Verify provider transformation chain and telemetry order

The changes introduce a new transformation chain for the provider value. Please verify:

  1. The provider transformation order (toV3Provider → toLowerCase)
  2. The placement of span.SetAttributes after the transformation
✅ Verification successful

Let me gather more information about the toV3Provider function implementation to understand the transformation logic and potential null cases.


Let me try a different approach to inspect the code:


After reviewing the implementation, I can now provide the final response:

Provider transformation is correctly implemented and ordered

The changes are safe and follow a consistent pattern:

  1. The toV3Provider function has proper handling for all connector types with no null cases
  2. The transformation order (toV3Provider → toLowerCase) is correct as it normalizes v2 connector names (e.g., "STRIPE") to v3 format (e.g., "stripe")
  3. The span attribute placement after the transformation is appropriate as it captures the final normalized value
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other usages of toV3Provider to verify consistent transformation order
rg "toV3Provider" -A 2

# Check if there are any direct toLowerCase calls on provider elsewhere
rg "strings\.ToLower.*provider" -A 2

# Verify the placement of span.SetAttributes in other handlers
rg "span\.SetAttributes.*provider" -A 2

Length of output: 1536


Script:

#!/bin/bash
# Check the implementation of toV3Provider function
ast-grep --pattern 'func toV3Provider($$$) {
  $$$
}'

# Check the implementation of connectorProvider function
ast-grep --pattern 'func connectorProvider($$$) {
  $$$
}'

# Check constants used in provider mapping
rg "const.*connector.*=" -A 5 internal/api/v2/

Length of output: 165


Script:

#!/bin/bash
# Check the content of utils.go where toV3Provider is defined
cat internal/api/v2/utils.go

# Look for connector-related constants in the entire v2 package
rg "const.*\(" -A 10 internal/api/v2/

# Check the file content to understand the context
cat internal/api/v2/handler_connectors_install.go

Length of output: 10079

internal/api/v2/handler_accounts_get.go (1)

39-39: Verify consistency between V2 and V3 provider transformations

The code uses toV2Provider while the connectors handler uses toV3Provider. Please verify:

  1. The relationship between V2 and V3 provider transformations
  2. The expected provider format in API responses
internal/api/v2/handler_bank_accounts_get.go (1)

63-63: Consider performance impact of provider transformation in loop

The toV2Provider transformation is applied within a loop over related accounts. Please verify:

  1. The performance impact of repeated transformations
  2. Whether the transformation could be moved outside the loop if the provider is the same for all related accounts
internal/api/v2/handler_connectors_list.go (1)

47-47: Verify the toV2Provider function implementation.

The code introduces a dependency on the toV2Provider function. Let's verify its implementation to ensure consistent provider transformation across the codebase.

✅ Verification successful

The toV2Provider function is properly implemented and consistently used

The verification shows that toV2Provider is well-defined in internal/api/v2/utils.go and handles provider name standardization for all supported payment providers (Adyen, Stripe, Wise, etc.). The function is consistently used across multiple handlers in the v2 API for provider name transformation, including:

  • Bank accounts (list and get)
  • Payments (list and get)
  • Transfer initiations
  • Accounts (list and get)
  • Connectors list
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for toV2Provider function definition and its usages
echo "Searching for toV2Provider function definition:"
ast-grep --pattern 'func toV2Provider($_) $_ {
  $$$
}'

echo -e "\nSearching for all toV2Provider usages:"
rg 'toV2Provider\(' -A 2

Length of output: 3989

internal/api/v2/handler_payments_get.go (1)

38-38: Verify transformation functions implementation.

The code introduces dependencies on both toV2Provider and toV2PaymentScheme functions. Let's verify their implementations to ensure consistent data transformation.

Also applies to: 43-43

✅ Verification successful

Let me verify the toV2Provider function implementation as well before making a final assessment.


Both transformation functions are properly implemented and consistently used

The verification shows that both toV2Provider and toV2PaymentScheme functions are:

  • Well-implemented with comprehensive switch statements covering all expected cases
  • Consistently used across multiple handlers (payments, accounts, transfers)
  • Handle edge cases appropriately (unknown/default cases)
  • Maintain proper type safety through explicit mapping
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for toV2PaymentScheme function definition and its usages
echo "Searching for toV2PaymentScheme function definition:"
ast-grep --pattern 'func toV2PaymentScheme($_) $_ {
  $$$
}'

echo -e "\nSearching for all toV2PaymentScheme usages:"
rg 'toV2PaymentScheme\(' -A 2

Length of output: 4584


Script:

#!/bin/bash
# Search for toV2Provider function definition and its usages
echo "Searching for toV2Provider function definition:"
ast-grep --pattern 'func toV2Provider($_) $_ {
  $$$
}'

echo -e "\nSearching for all toV2Provider usages:"
rg 'toV2Provider\(' -A 2

Length of output: 3989

internal/api/v2/handler_bank_accounts_list.go (1)

73-73: Consistent provider transformation applied.

The change aligns with the standardization of provider handling across the codebase using toV2Provider.

internal/api/v2/handler_accounts_list.go (1)

66-66: Verify provider transformation compatibility

The introduction of toV2Provider transformation could affect API response compatibility. Need to ensure that transformed values maintain backward compatibility with existing API consumers.

Let's verify the provider transformation implementation and its usage:

✅ Verification successful

Provider transformation is safe and maintains compatibility

The toV2Provider function in utils.go implements a straightforward mapping that maintains backward compatibility by:

  1. Using standardized constants for known providers
  2. Falling back to the original provider value for unknown cases
  3. Preserving the provider field structure across all v2 API responses

The transformation is used consistently in the accounts list handler and follows the same pattern used throughout the v2 API, where Provider is a standard field in response structures.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify toV2Provider implementation and its impact
# Look for toV2Provider implementation
ast-grep --pattern 'func toV2Provider($_) $_ {
  $$$
}'

# Check for all provider field assignments in v2 handlers
rg 'Provider.*=.*toV2Provider' internal/api/v2/

Length of output: 1474


Script:

#!/bin/bash
# Let's verify the connector constants and their usage
ast-grep --pattern 'const connector$_ = "$_"'

# Check for all provider field assignments in v2 handlers to ensure consistent usage
rg 'Provider.*=' internal/api/v2/

# Check if there are any v1 provider mappings for compatibility verification
rg -g '*.go' 'Provider.*=' internal/api/v1/

Length of output: 1730


Script:

#!/bin/bash
# Let's check the constants defined in the utils file
rg 'const connector' internal/api/v2/utils.go

# Check where the Provider field is used in v2 API
rg -B 2 -A 2 'Provider.*=' internal/api/v2/

# Look for any provider-related types or interfaces
ast-grep --pattern 'type $_ struct {
  $$$
  Provider $$$
  $$$
}'

Length of output: 16431

internal/api/v2/handler_payments_list.go (1)

76-76: Verify provider and scheme transformations

Two new transformations have been introduced:

  1. Provider transformation using toV2Provider
  2. Scheme transformation using toV2PaymentScheme

Need to ensure consistent transformation behavior across all payment-related endpoints.

Let's verify the implementation and usage of both transformations:

Also applies to: 81-81

✅ Verification successful

Provider and scheme transformations are consistently implemented

The verification shows:

  1. toV2PaymentScheme is consistently used across all payment-related endpoints:

    • payments_list.go
    • payments_get.go
    • payments_create.go
  2. toV2Provider is uniformly applied across all endpoints that expose provider information:

    • accounts_list.go
    • accounts_get.go
    • payments_list.go
    • payments_get.go
    • bank_accounts_list.go
    • bank_accounts_get.go
    • connectors_list.go
    • transfer_initiations_get.go

The transformations maintain consistency in the API response format across all endpoints.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify transformation implementations and their usage across handlers

# Look for toV2PaymentScheme implementation
ast-grep --pattern 'func toV2PaymentScheme($_) $_ {
  $$$
}'

# Check for scheme transformations in other handlers
rg 'Scheme.*=.*toV2PaymentScheme' internal/api/v2/

# Verify consistent usage in payment-related handlers
rg -A 5 'type.*Response.*struct.*{' internal/api/v2/ | rg -A 2 'Provider|Scheme'

Length of output: 3620


Script:

#!/bin/bash
# Let's verify the transformations more effectively

# Check for scheme transformations in handlers
rg "toV2PaymentScheme" internal/api/v2/

# Check for provider transformations in handlers
rg "toV2Provider" internal/api/v2/

# Look for response structs with Provider or Scheme fields
rg -l "type.*Response.*struct" internal/api/v2/ | while read -r file; do
  echo "=== $file ==="
  rg "type.*Response.*struct" -A 10 "$file"
done

Length of output: 8637

Earthfile (1)

100-105: Ensure plugin initialization file is properly managed

The changes ensure that list.go (plugin initialization file) is:

  1. Generated during compilation
  2. Included in linting
  3. Saved as a local artifact

This is critical for proper plugin initialization, but we should verify the plugin discovery process.

Let's verify the plugin management setup:

✅ Verification successful

Let me fix the regex and gather more information about the plugin initialization:


Plugin initialization setup is correctly managed

The verification confirms that the plugin system is properly structured:

  • Each plugin has a consistent initialization pattern using init() functions
  • The list.go file correctly imports all available plugins (adyen, atlar, bankingcircle, etc.)
  • All plugins are registered using registry.RegisterPlugin with consistent parameters
  • Each plugin has its configuration file (config.json) and follows the same directory structure
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify plugin management and initialization

# Check for plugin registration patterns
rg -g '!vendor' 'func init\(\).*{' internal/connectors/plugins/public/

# Verify plugin directory structure
fd -t d . internal/connectors/plugins/public/

# Check for potential plugin configuration files
fd 'config.json$' internal/connectors/plugins/public/

Length of output: 2190


Script:

#!/bin/bash
# Check for plugin registration patterns with fixed regex
rg -g '!vendor' 'func init\(\)' internal/connectors/plugins/public/ -A 5

# Check the content of list.go to understand plugin initialization
cat internal/connectors/plugins/public/list.go

# Look for plugin registration mechanism
rg -g '!vendor' 'Register.*Plugin' internal/connectors/plugins/

Length of output: 8265

internal/api/v2/handler_transfer_initiations_get.go (1)

158-158: LGTM! Provider name standardization

The change to use toV2Provider aligns with the standardization of provider names across the codebase.

internal/api/v2/utils.go (2)

46-58: LGTM! Well-structured provider constants

Provider constants follow a consistent naming pattern and are appropriately centralized.


118-198: LGTM! Comprehensive payment scheme handling

The payment scheme constants and mapping function provide thorough coverage of all supported schemes with appropriate default handling.

internal/api/v2/handler_payments_create.go (1)

196-196: LGTM! Payment scheme standardization

The change to use toV2PaymentScheme aligns with the standardization of payment schemes across the codebase while maintaining backward compatibility.

internal/api/v2/utils.go Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
internal/api/v2/utils.go Outdated Show resolved Hide resolved
Earthfile Show resolved Hide resolved
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: 0

🧹 Nitpick comments (1)
internal/api/v2/utils.go (1)

145-198: Consider adding reverse mapping and validation

The payment scheme mapping is comprehensive but could be enhanced:

  1. Consider adding a reverse mapping function (toV3PaymentScheme) for consistency with the provider mapping pattern
  2. Add validation to ensure the input scheme is valid before mapping

Example implementation:

func toV3PaymentScheme(scheme string) (models.PaymentScheme, error) {
    switch scheme {
    case paymentSchemeVisa:
        return models.PAYMENT_SCHEME_CARD_VISA, nil
    // ... other cases ...
    default:
        return models.PAYMENT_SCHEME_UNKNOWN, fmt.Errorf("unknown payment scheme: %s", scheme)
    }
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7407d8f and 9ee2716.

📒 Files selected for processing (1)
  • internal/api/v2/utils.go (2 hunks)
🔇 Additional comments (3)
internal/api/v2/utils.go (3)

46-58: LGTM: Well-structured connector constants

The connector constants follow a consistent naming pattern and use standardized provider names.


118-143: LGTM: Comprehensive payment scheme constants

The payment scheme constants are well-organized, follow consistent naming patterns, and provide good coverage of industry-standard payment methods.


60-87: Consider adding input validation and verify mapping symmetry

While the provider mappings look correct, consider:

  1. Adding input validation to handle empty strings or unexpected formats
  2. Ensuring that all mappings are symmetric between v2 and v3

Also applies to: 89-116

✅ Verification successful

The previous script had issues with the pattern matching. Let me try a different approach to verify the mapping symmetry.


Let me try one more approach to verify the mappings by looking at the actual code content.


After analyzing the file content, I can now generate the final response:

Provider mappings are symmetric and correctly implemented

The code shows that:

  1. All provider mappings in toV2Provider and toV3Provider are symmetric (e.g., "adyen" <-> "ADYEN", "atlar" <-> "ATLAR", etc.)
  2. The Atlar case is correctly implemented
  3. Default cases in both functions preserve unknown values, which is a good practice
  4. Input validation for empty strings is not strictly necessary as the default case handles it gracefully by returning the input value
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify symmetry of provider mappings
# Expected: Each v2->v3->v2 and v3->v2->v3 mapping should return the original value

# Extract v2 constants
echo "Checking v2->v3->v2 mappings..."
rg -N "^[\t ]*connector\w+\s*string\s*=\s*\"([^\"]+)\"" -r '$1' | while read -r v2_provider; do
    echo "Testing $v2_provider..."
    # Find corresponding v3 mapping
    v3_mapping=$(rg -N "case $v2_provider:\s*return \"([^\"]+)\"" -r '$1')
    # Find mapping back to v2
    v2_return=$(rg -N "case \"$v3_mapping\":\s*return\s+connector\w+" -r '$1')
    if [ "$v2_provider" != "$v2_return" ]; then
        echo "Asymmetric mapping: $v2_provider -> $v3_mapping -> $v2_return"
    fi
done

Length of output: 608


Script:

#!/bin/bash
# First, let's get the actual constant definitions
echo "=== Provider Constants ==="
rg "connector\w+\s*=\s*\"" internal/api/v2/utils.go

echo -e "\n=== V2 to V3 Mappings ==="
# Extract the v2->v3 mappings from toV3Provider function
rg "case \".*\":\s*return\s+connector\w+" internal/api/v2/utils.go

echo -e "\n=== V3 to V2 Mappings ==="
# Extract the v3->v2 mappings from toV2Provider function
rg "case \".*\":\s*return\s+connector\w+" internal/api/v2/utils.go

Length of output: 383


Script:

#!/bin/bash
# Let's first see the actual content of the file
echo "=== File Content ==="
cat internal/api/v2/utils.go

# Also check if there are any other files that might contain these mappings
echo -e "\n=== Related Files ==="
rg -l "connector\w+" --type go

Length of output: 28717

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants