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

feat(http): added pathParams field and renamed the tab ro URL params #1831

Merged
merged 3 commits into from
Dec 27, 2024

Conversation

sandeepdsvs
Copy link
Contributor

@sandeepdsvs sandeepdsvs commented Dec 9, 2024

What are the changes introduced in this PR?

Added pathParams field and renamed the tab ro URL params

What is the related Linear task?

Resolves INT-2908

Please explain the objectives of your changes below

Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

N/A

Any new dependencies introduced with this change?

N/A

Any new checks got introduced or modified in test suites. Please explain the changes.

N/A


Developer checklist

  • My code follows the style guidelines of this project

  • No breaking changes are being introduced.

  • All related docs linked with the PR?

  • All changes manually tested?

  • Any documentation changes needed with this change?

  • I have executed schemaGenerator tests and updated schema if needed

  • Are sensitive fields marked as secret in definition config?

  • My test cases and placeholders use only masked/sample values for sensitive fields

  • Is the PR limited to 10 file changes & one task?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?

  • Verified that there are no credentials or confidential data exposed with the changes.

Summary by CodeRabbit

  • New Features

    • Added a new configuration entry for pathParams in HTTP settings, enhancing request flexibility.
    • Introduced a new field for path parameters in the user interface, improving clarity in configuration settings.
    • Renamed the "Query Parameters" section to "Request URL" for better organization.
  • Bug Fixes

    • Enhanced error messages for validation failures in existing test cases, providing clearer feedback.
  • Tests

    • Added a new test case for configurations utilizing pathParams, ensuring proper validation and functionality.

Copy link

coderabbitai bot commented Dec 9, 2024

Walkthrough

The changes introduce a new configuration entry, "pathParams", to the HTTP destination settings across multiple files. This includes updates to the db-config.json to allow path parameters in requests, modifications to the schema.json to define the structure of these parameters, and enhancements to the ui-config.json for improved user input organization. Additionally, a new test case for validating the use of path parameters is added, along with refinements to error messaging in existing tests.

Changes

File Path Change Summary
src/configurations/destinations/http/db-config.json New entry "pathParams" added to defaultConfig array in destConfig object.
src/configurations/destinations/http/schema.json New property pathParams added to configSchema, defined as an array of objects with a path. Updated patterns for several properties to disallow starting with $.
src/configurations/destinations/http/ui-config.json Added pathParams field under "Request URL"; renamed "Query Parameters" to "Request URL". Updated regex patterns for "Value" and "Key" fields in relevant sections.
test/data/validation/destinations/http.json New test case "With pathParams" added; existing tests updated for better error messages.

Possibly related PRs

  • fix: http enchancements #1759: This PR modifies the ui-config.json file, which is also affected by the main PR, specifically in the context of HTTP destination configurations, although it does not introduce the pathParams entry.
  • feat: update mapping component regex for HTTP destination #1820: This PR updates the ui-config.json and schema.json files, which are directly related to the changes in the main PR by enhancing validation logic for HTTP configurations, including the introduction of new regex patterns that could relate to the handling of pathParams.
  • fix(http): updated property mapping regex #1830: This PR also modifies the ui-config.json and schema.json files, focusing on updating regex patterns for property mapping, which is relevant to the changes made in the main PR regarding the addition of pathParams.

Suggested reviewers

  • lvrach
  • am6010
  • ssbeefeater
  • debanjan97
  • cisse21
  • ruchiramoitra
  • shrouti1507
  • 1abhishekpandey
  • ItsSudip
  • krishna2020

🐇 In the fields where data flows,
New paths for parameters grow.
With structure clear and tests anew,
Our configs shine, all bright and true!
Hopping forth, we celebrate,
Enhancements made, oh what a fate! 🌟


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.

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (2c683fe) to head (916fa8a).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff            @@
##           develop     #1831   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines           53        53           
  Branches         7         7           
=========================================
  Hits            53        53           

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

Copy link

@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

🧹 Outside diff range and nitpick comments (3)
test/data/validation/destinations/http.json (1)

582-627: LGTM! Basic test case for pathParams

The test case appropriately demonstrates the basic usage of the new pathParams field.

Consider adding additional test cases to validate:

  • Empty path parameter
  • Invalid JSON path syntax
  • Multiple path parameters
  • Path parameter with constant value
src/configurations/destinations/http/ui-config.json (1)

496-510: Consider enhancing the placeholder text

The configuration is well-structured with appropriate validation, but the placeholder could be more descriptive.

Consider updating the placeholder to better illustrate the expected format:

-    "placeholder": "$.userId or users",
+    "placeholder": "e.g: $.properties.userId or constant_value",
src/configurations/destinations/http/schema.json (1)

46-57: Consider adding validation rules for path parameters

The schema would benefit from additional validation rules for path parameters in the allOf section, similar to other conditional validations present in the schema.

Consider adding validation rules to ensure path parameters are properly handled when specific HTTP methods are used:

     "allOf": [
+      {
+        "if": {
+          "properties": {
+            "method": {
+              "enum": ["GET", "DELETE"]
+            }
+          }
+        },
+        "then": {
+          "properties": {
+            "pathParams": {
+              "type": "array",
+              "maxItems": 10
+            }
+          }
+        }
+      },
       {
         "if": {
           "properties": {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d0258b1 and 8984b6b.

📒 Files selected for processing (4)
  • src/configurations/destinations/http/db-config.json (1 hunks)
  • src/configurations/destinations/http/schema.json (1 hunks)
  • src/configurations/destinations/http/ui-config.json (1 hunks)
  • test/data/validation/destinations/http.json (1 hunks)
🔇 Additional comments (3)
src/configurations/destinations/http/db-config.json (1)

48-48: LGTM! Addition of pathParams configuration

The placement of pathParams in the defaultConfig array is appropriate, maintaining a logical grouping with other HTTP request parameters.

src/configurations/destinations/http/ui-config.json (1)

493-493: LGTM! Improved tab name clarity

Renaming to "URL Parameters" better represents the section's purpose, encompassing both path and query parameters.

src/configurations/destinations/http/schema.json (1)

46-57: LGTM! The pathParams implementation is functionally correct

The implementation correctly defines the structure for path parameters with appropriate pattern matching for both dynamic and static values. This addition enhances the HTTP destination's capability to handle URL path parameters.

Let's verify the integration with other configuration files:

✅ Verification successful

The pathParams implementation is properly integrated across the codebase

The verification confirms that the pathParams implementation is correctly integrated:

  1. The schema.json defines the correct structure and validation pattern for pathParams
  2. The ui-config.json includes pathParams in the URL Parameters tab under Request Body configuration
  3. The db-config.json lists pathParams in the defaultConfig array, making it available across all supported source types
  4. Test cases in test/data/validation/destinations/http.json include validation for pathParams functionality

The implementation is consistent across all configuration files and properly tested.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the consistency of pathParams implementation across related files

# Test 1: Check if ui-config.json has been updated with the new field
rg -l "pathParams" --type json

# Test 2: Check for any existing usages of path parameters in test files
rg "pathParams" --type json -g "test/**"

Length of output: 414


Script:

#!/bin/bash
# Let's examine the implementation details in the related files

# Check ui-config.json for pathParams configuration
echo "=== ui-config.json content ==="
cat src/configurations/destinations/http/ui-config.json

# Check db-config.json for pathParams configuration
echo -e "\n=== db-config.json content ==="
cat src/configurations/destinations/http/db-config.json

# Check test case implementation
echo -e "\n=== test case content ==="
cat test/data/validation/destinations/http.json

Length of output: 41736

src/configurations/destinations/http/schema.json Outdated Show resolved Hide resolved
Copy link

@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

♻️ Duplicate comments (1)
src/configurations/destinations/http/schema.json (1)

46-54: 🛠️ Refactor suggestion

Consider aligning pathParams structure with existing parameter fields

The implementation of pathParams differs from similar fields like queryParams and headers. While functionally correct, this inconsistency might affect parameter mapping and maintenance.

Apply this diff to align with existing parameter fields:

   "pathParams": {
     "type": "array",
     "items": {
       "type": "object",
       "properties": {
-        "path": {
+        "to": {
+          "type": "string",
+          "pattern": "^(?!\\$)[A-Za-z0-9!#$%&'*+.^_`|~-]{1,100}$"
+        },
+        "from": {
           "type": "string",
           "pattern": "^\\$(?:\\.|(\\.(\\w+|\\*)|\\[\\d+\\]|\\[('\\w+'|\"\\w+\")\\]|\\[\\*\\]|\\.\\w+\\(\\))*)$|^(?!\\$)[A-Za-z0-9!#$%&'*+.^_`|~-]{1,100}$"
         }
       }
     }
   },
🧹 Nitpick comments (1)
src/configurations/destinations/http/schema.json (1)

46-54: Add validation constraints for pathParams

Consider adding the following validations to prevent potential issues:

  1. Minimum/maximum items constraint for the array
  2. Required properties within items
  3. Additional pattern validation for path parameter names

Apply these additional schema validations:

   "pathParams": {
     "type": "array",
+    "minItems": 1,
+    "maxItems": 10,
     "items": {
       "type": "object",
+      "required": ["to", "from"],
       "properties": {
         "to": {
           "type": "string",
+          "minLength": 1,
           "pattern": "^(?!\\$)[A-Za-z0-9!#$%&'*+.^_`|~-]{1,100}$"
         },
         "from": {
           "type": "string",
           "pattern": "^\\$(?:\\.|(\\.(\\w+|\\*)|\\[\\d+\\]|\\[('\\w+'|\"\\w+\")\\]|\\[\\*\\]|\\.\\w+\\(\\))*)$|^(?!\\$)[A-Za-z0-9!#$%&'*+.^_`|~-]{1,100}$"
         }
       }
     }
   },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 67de4a3 and 916fa8a.

📒 Files selected for processing (2)
  • src/configurations/destinations/http/schema.json (3 hunks)
  • src/configurations/destinations/http/ui-config.json (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/configurations/destinations/http/ui-config.json
🔇 Additional comments (1)
src/configurations/destinations/http/schema.json (1)

41-41: LGTM: Pattern updates are consistent and well-structured

The pattern modifications consistently enforce that values cannot start with '$' while maintaining the existing validation rules.

Also applies to: 65-65, 69-69, 81-81, 85-85

@sandeepdsvs sandeepdsvs merged commit 04797e9 into develop Dec 27, 2024
15 checks passed
@sandeepdsvs sandeepdsvs deleted the feat.path-params-http branch December 27, 2024 12:35
@coderabbitai coderabbitai bot mentioned this pull request Dec 30, 2024
11 tasks
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.

3 participants