8000 fix(atlar): fix json tag with backward compatibility by paul-nicolas · Pull Request #366 · formancehq/payments · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(atlar): fix json tag with backward compatibility #366

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

Merged
merged 1 commit into from
Mar 19, 2025
Merged

Conversation

paul-nicolas
Copy link
Contributor
@paul-nicolas paul-nicolas commented Mar 19, 2025

Fixes PMNT-63

Copy link
Contributor
coderabbitai bot commented Mar 19, 2025

Walkthrough

The pull request modifies the configuration for the "atlar" plugin by changing the JSON tag for the BaseURL field in the Config struct from "baseURL" to "baseUrl". This adjustment affects how JSON data is serialized and deserialized, ensuring consistency with the updated key format while adhering to the existing validation constraints.

Changes

File(s) Change Summary
internal/connectors/.../atlar/config.go - Updated the JSON tag for BaseURL from "baseURL" to "baseUrl" in the Config struct.

P 8000 oem

I'm a little bunny, hopping through the code,
Nibbling on changes on my secret mode.
JSON keys now prance in a rhythm so true,
"baseUrl" shines bright, like morning dew.
With joyful hops, I celebrate what's new!

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 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 a5a6815 and 9f42a94.

⛔ Files ignored due to path filters (1)
  • openapi.yaml is excluded by !**/*.yaml
📒 Files selected for processing (1)
  • internal/connectors/plugins/public/atlar/config.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/connectors/plugins/public/atlar/config.go

🪧 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.
  • @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 changed the title fix(atlar): fix json tag with backweard compatibility fix(atlar): fix json tag with backward compatibility Mar 19, 2025
@paul-nicolas paul-nicolas reopened this Mar 19, 2025
@paul-nicolas paul-nicolas marked this pull request as ready for review March 19, 2025 13:48
@paul-nicolas paul-nicolas requested a review from a team as a code owner March 19, 2025 13:48
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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 2

🧹 Nitpick comments (2)
internal/connectors/plugins/public/atlar/config.go (2)

11-11: Fix JSON formatting in comment.

The comment contains malformed JSON with extra closing curly braces at the end (}}}).

Remove the extra closing braces to ensure the JSON is properly formatted.

🧰 Tools
🪛 Gitleaks (8.21.2)

11-11: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


11-14: Document the purpose of the configuration comment.

The newly added comment contains a JSON-like configuration structure, but its purpose isn't clear. Is this intended to be documentation, an example configuration, or something else?

Consider adding a brief explanation before the JSON to clarify its purpose, such as:

+// Example configuration for the Atlar plugin:
 // {"name":"atlar","baseUrl":"https://api.atlar.com",...}
🧰 Tools
🪛 Gitleaks (8.21.2)

11-11: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🛑 Comments failed to post (2)
internal/connectors/plugins/public/atlar/config.go (2)

11-11: ⚠️ Potential issue

Remove API credentials from code comments.

The comment contains what appears to be real API credentials (accessKey and secret). These should never be committed to the codebase as they could lead to security breaches if the code is made public.

Replace the credentials with placeholder values like "<YOUR_ACCESS_KEY>" and "<YOUR_SECRET>". Also, consider documenting that these values should be retrieved from environment variables or a secure configuration store.

-// {"name":"atlar","baseUrl":"https://api.atlar.com","pollingPeriod":"120s","transferInitiationStatusPollingPeriod":"120s","accessKey":"7bRhJPLMzTZK8xohVUVc","secret":"YgtdOM_7gRIqgSySivMpJA8Nu8SXWvzOL9UJm5GdJnoHELQq_s2Zdxkz3ls3mqpx9Tyi","pageSize":15}}}
+// {"name":"atlar","baseUrl":"https://api.atlar.com","pollingPeriod":"120s","transferInitiationStatusPollingPeriod":"120s","accessKey":"<YOUR_ACCESS_KEY>","secret":"<YOUR_SECRET>","pageSize":15}
📝 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.

// {"name":"atlar","baseUrl":"https://api.atlar.com","pollingPeriod":"120s","transferInitiationStatusPollingPeriod":"120s","accessKey":"<YOUR_ACCESS_KEY>","secret":"<YOUR_SECRET>","pageSize":15}
🧰 Tools
🪛 Gitleaks (8.21.2)

11-11: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


14-14: 💡 Verification agent

🧩 Analysis chain

Consider adding backward compatibility for JSON field name change.

The JSON tag for BaseURL has been changed from "baseURL" to "baseUrl". While this change aligns with the naming convention used in the comment, it could potentially break backward compatibility with existing configurations.

Since the PR title mentions "backward compatibility", ensure that there's a mechanism to handle both the old and new field names during deserialization. Consider using a custom unmarshaler or adding a fallback field.


🏁 Script executed:

#!/bin/bash
# Check if there's any backward compatibility handling for the baseURL/baseUrl field
rg -A 5 -B 5 "UnmarshalJSON|json.Unmarshal.*Config|baseURL" --type go internal/connectors/plugins/public/atlar/

Length of output: 4911


Backward Compatibility for JSON Field Change Required

The change from "baseURL" to "baseUrl" in the JSON tag of the BaseURL field in internal/connectors/plugins/public/atlar/config.go has been verified to lack any fallback mechanism. Notably, the tests in plugin_test.go validate the presence of the legacy "baseURL" field, suggesting that existing configurations might break due to this change.

  • Issue: The PR alters the JSON tag without implementing backward compatibility, meaning that incoming JSON using the legacy "baseURL" won’t be correctly unmarshaled.
  • Suggestion: Implement a custom unmarshaler for the configuration struct (or an equivalent fallback mechanism) that checks for both "baseURL" and "baseUrl". This will ensure seamless handling of both new and legacy configurations.

Copy link
codecov bot commented Mar 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.43%. Comparing base (fd2cbb0) to head (9f42a94).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #366      +/-   ##
==========================================
- Coverage   73.44%   73.43%   -0.02%     
==========================================
  Files         538      538              
  Lines       26620    26620              
==
8000
========================================
- Hits        19552    19549       -3     
- Misses       6054     6057       +3     
  Partials     1014     1014              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paul-nicolas paul-nicolas enabled auto-merge (squash) March 19, 2025 13:58
@paul-nicolas paul-nicolas merged commit 6dcb32c into main Mar 19, 2025
7 checks passed
@paul-nicolas paul-nicolas deleted the fix/atlar branch March 19, 2025 14:03
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
0