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

Add AccountCreationSchema to ConnectorMetadata #285

Merged
merged 6 commits into from
Jan 23, 2025

Conversation

danlarkin
Copy link
Contributor

@danlarkin danlarkin commented Jan 14, 2025

Extend ConnectorMetadata message with a new field of type AccountCreationSchema to capture arbitrary account creation details.

Summary by CodeRabbit

  • New Features

    • Added comprehensive account creation schema validation.
    • Introduced flexible account creation field types (string, boolean, list, int64, map).
    • Enhanced connector metadata with account creation configuration support.
  • Improvements

    • Implemented robust error handling for account creation fields.
    • Added multi-error validation capabilities for detailed field validation.
    • Improved syntax for validation rules across various message definitions.
    • Corrected formatting issues in existing message definitions for clarity.

@danlarkin danlarkin requested a review from jirwin as a code owner January 14, 2025 18:02
Copy link

coderabbitai bot commented Jan 14, 2025

Warning

Rate limit exceeded

@danlarkin has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 56 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 13da073 and a009d79.

⛔ Files ignored due to path filters (1)
  • pb/c1/connector/v2/connector.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (1)
  • proto/c1/connector/v2/connector.proto (2 hunks)

Walkthrough

The changes introduce a comprehensive account creation schema for connector metadata, defining new message types that support various field types such as strings, booleans, lists, integers, and maps. The implementation adds robust validation mechanisms to ensure data integrity during account creation. New methods for validation are added to the ConnectorAccountCreationSchema and its associated field types, enhancing error reporting and handling. Additionally, minor syntactical corrections are made across several protocol files without altering functionality.

Changes

File Change Summary
proto/c1/connector/v2/connector.proto Added new message types for account creation: ConnectorAccountCreationSchema, Field, StringField, StringListField, BoolField, IntField, MapField. Updated ConnectorMetadata to include account_creation_schema.
pb/c1/connector/v2/connector.pb.validate.go Implemented validation methods (Validate(), ValidateAll(), validate()) for new account creation message types, added multi-error and validation error types for comprehensive error handling.
proto/c1/connector/v2/resource.proto Updated CredentialOptions message: corrected syntax in RandomPassword and reformatted NoPassword.
proto/c1/connector/v2/ticket.proto Removed empty lines at the end of the file.
proto/c1/connectorapi/baton/v1/baton.proto Corrected syntax in validation rules for string fields across multiple messages.

Possibly related PRs

Suggested reviewers

  • jirwin
  • ggreer
  • btipling

Poem

🐰 Validation's dance, a rabbit's delight,
Fields of schema, now shining bright!
Strings and bools, lists galore,
Errors caught at every door 🚪
Account creation, safe and sound, hooray! 🎉


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

@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 (3)
pb/c1/connector/v2/connector.pb.validate.go (1)

1816-2976: Consider reducing code duplication in validation error types.

The validation functions and error types for AccountCreationSchema and related messages (AccountCreationField, AccountCreationStringField, etc.) are repetitive. Refactoring these to reduce duplication can enhance maintainability.

You might consider creating generic validation error types or helper functions that can handle common validation patterns across different message types. This adheres to the DRY (Don't Repeat Yourself) principle and makes future maintenance easier.

proto/c1/connector/v2/connector.proto (2)

130-135: Specify validation rules for AccountCreationStringField.

Currently, the value_validator field in AccountCreationStringField references validate.StringRules. Ensure that appropriate string validation rules are set to enforce constraints like minimum and maximum length, regex patterns, etc.

Defining explicit validation rules enhances data integrity and helps prevent invalid data from being processed.


137-140: Remove unused value field in AccountCreationBoolField.

The AccountCreationBoolField message contains a value field that may not be necessary in this context since the actual value would likely be provided at runtime.

Consider removing the value field or clarifying its purpose to avoid confusion.

 message AccountCreationBoolField {
-  bool value = 1;
   optional bool default_value = 2;
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4a89933 and 10dec97.

⛔ Files ignored due to path filters (1)
  • pb/c1/connector/v2/connector.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (2)
  • pb/c1/connector/v2/connector.pb.validate.go (2 hunks)
  • proto/c1/connector/v2/connector.proto (2 hunks)
🔇 Additional comments (5)
pb/c1/connector/v2/connector.pb.validate.go (1)

557-584: Validation added for AccountCreationSchema in ConnectorMetadata.

The added code correctly implements validation for the new AccountCreationSchema field in the ConnectorMetadata message. This ensures that any embedded messages are properly validated, maintaining data integrity.

proto/c1/connector/v2/connector.proto (4)

48-48: Addition of account_creation_schema to ConnectorMetadata.

The inclusion of the AccountCreationSchema field in the ConnectorMetadata message enhances the schema to support detailed account creation configurations.

Ensure that this addition maintains backward compatibility. Since the new field is presumably optional, existing consumers of ConnectorMetadata should not be impacted. However, it's prudent to verify that all systems interacting with this message can handle the new field gracefully.


110-155: Well-structured definition of account creation messages.

The new messages AccountCreationSchema, AccountCreationField, and their related types are well-defined. They provide flexibility for various field types and validation rules, allowing for comprehensive account creation configurations.


115-128: Clarify the use of oneof in AccountCreationField.

The AccountCreationField message uses a oneof to represent different field types. Ensure that the handling of this oneof is correctly implemented in the codebase, and consider providing documentation or comments for clarity.

It's important to confirm that serialization and deserialization correctly manage the oneof fields. Additionally, make sure that any code handling AccountCreationField accounts for the possibility of different field types.


152-155: Ensure proper validation for AccountCreationMapField.

The AccountCreationMapField includes a value_validator of type validate.MapRules. Double-check that the map validation rules are properly defined to enforce key and value constraints.

Define specific rules for map keys and values to prevent invalid data entries.

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

🧹 Nitpick comments (1)
proto/c1/connector/v2/connector.proto (1)

123-129: Consider renaming fields in the oneof declaration for clarity and to avoid potential keyword conflicts.

Using field names like bool, i, and m within the oneof field may lead to confusion or conflicts with reserved keywords in some languages or tools. Renaming these fields to more descriptive names such as bool_field, int_field, and map_field can enhance readability and maintainability.

Apply this diff to rename the fields:

       oneof field {
         StringField str = 100;
-        BoolField bool = 101;
+        BoolField bool_field = 101;
         StringListField str_list = 102;
-        IntField i = 103;
+        IntField int_field = 103;
-        MapField m = 104;
+        MapField map_field = 104;
       }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 10dec97 and 0e15df9.

⛔ Files ignored due to path filters (1)
  • pb/c1/connector/v2/connector.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (5)
  • pb/c1/connector/v2/connector.pb.validate.go (2 hunks)
  • proto/c1/connector/v2/connector.proto (3 hunks)
  • proto/c1/connector/v2/resource.proto (1 hunks)
  • proto/c1/connector/v2/ticket.proto (0 hunks)
  • proto/c1/connectorapi/baton/v1/baton.proto (6 hunks)
💤 Files with no reviewable changes (1)
  • proto/c1/connector/v2/ticket.proto
✅ Files skipped from review due to trivial changes (2)
  • proto/c1/connector/v2/resource.proto
  • proto/c1/connectorapi/baton/v1/baton.proto
🔇 Additional comments (5)
pb/c1/connector/v2/connector.pb.validate.go (4)

557-584: Validation logic for AccountCreationSchema is correctly integrated.

The added validation code for AccountCreationSchema in the ConnectorMetadata struct follows the existing validation patterns. It appropriately checks for both ValidateAll() and Validate() methods and handles validation errors consistently with other fields.


1817-1955: Validate methods for ConnectorAccountCreationSchema are properly implemented.

The Validate and ValidateAll methods for ConnectorAccountCreationSchema correctly implement the validation logic. The code iterates over the FieldMap, sorts the keys for consistent order, and validates each Field entry, handling errors as expected.


1966-2292: Ensure comprehensive validation in ConnectorAccountCreationSchema_Field.

The validation function for ConnectorAccountCreationSchema_Field correctly handles the oneof field by checking for typed-nil values and validating the embedded field types. This ensures that only one field is set and that it is valid, maintaining the integrity of the schema.


2293-2733: Nested field types have appropriate validation methods.

The Validate methods for the nested field types (StringField, StringListField, BoolField, IntField, MapField) are correctly defined. They handle default values appropriately and ensure that any embedded data is validated according to the defined rules.

proto/c1/connector/v2/connector.proto (1)

132-147: Verify the use of the optional keyword for field declarations in proto3.

The optional keyword was reintroduced in proto3 with version 3.12 of the Protocol Buffers compiler (protoc). Ensure that your development environment and tooling support protoc version 3.12 or higher to prevent any compatibility issues.

Run the following script to check the installed protoc version:

✅ Verification successful

The use of optional keyword in proto3 is correctly implemented.

The codebase demonstrates proper usage of proto3 syntax with optional fields. The explicit syntax = "proto3"; declaration and consistent field definitions across multiple proto files indicate a well-structured protobuf implementation. The presence of protobuf-related dependencies in the vendor directory suggests proper dependency management.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the installed version of protoc compiler.

# Test: Get the protoc version. Expected: Version 3.12 or higher.
protoc --version

Length of output: 115


Script:

#!/bin/bash
# Check proto syntax version and search for build configs
echo "=== Checking proto syntax ==="
rg "syntax = \"proto3\"" proto/c1/connector/v2/connector.proto -A 1

echo -e "\n=== Searching for build configurations ==="
fd "BUILD|.bazel|CMakeLists.txt|Makefile|package.json" --type f

echo -e "\n=== Looking for similar optional usage ==="
rg "optional \w+" --type proto

Length of output: 1263


Script:

#!/bin/bash
# Find and examine proto files and build configurations
echo "=== Finding all proto files ==="
fd '\.proto$'

echo -e "\n=== Checking proto files content ==="
fd '\.proto$' -x cat {}

echo -e "\n=== Checking build files for protobuf version ==="
rg -i "protobuf|protoc" Makefile

Length of output: 79961

}

message StringListField {
// validator rules for value. may be empty.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment seems out of date

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

🧹 Nitpick comments (2)
proto/c1/connector/v2/connector.proto (2)

9-9: Unused import: google/protobuf/timestamp.proto.

The imported timestamp.proto does not appear to be used in this file. Consider removing it to clean up unnecessary dependencies.


121-121: Verify the necessity of the deprecated field in the Field message.

The Field message includes a boolean deprecated field. If its purpose is to indicate deprecation status, consider using the protobuf built-in option [deprecated = true] on fields to leverage compiler warnings and tooling support. If it serves a different purpose, ensure that this is clearly documented.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0e15df9 and 9ea719c.

⛔ Files ignored due to path filters (1)
  • pb/c1/connector/v2/connector.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (2)
  • pb/c1/connector/v2/connector.pb.validate.go (2 hunks)
  • proto/c1/connector/v2/connector.proto (3 hunks)
🔇 Additional comments (7)
pb/c1/connector/v2/connector.pb.validate.go (3)

557-584: Validation logic for AccountCreationSchema is correctly implemented.

The validation methods for AccountCreationSchema within ConnectorMetadata are consistent with existing patterns and ensure proper error handling.


1816-2876: Validation methods for ConnectorAccountCreationSchema and nested fields are well-implemented.

The added validation functions provide comprehensive checks for the new message structures, maintaining consistency and completeness in validation.


1840-1846: Good practice: Sorting map keys for deterministic iteration.

Sorting the keys in FieldMap ensures consistent validation order, which is beneficial for testing and debugging.

proto/c1/connector/v2/connector.proto (4)

49-49: Addition of account_creation_schema field is appropriate.

The new field account_creation_schema is correctly added to ConnectorMetadata with field number 9, following proper sequencing.


111-150: Definition of ConnectorAccountCreationSchema and nested messages is well-structured.

The message definitions are clear and align with protobuf best practices, enhancing the schema for account creation configurations.


131-145: Verify the usage of the optional keyword in proto3 messages.

The optional keyword is used in the default_value fields of StringField, BoolField, and IntField. Ensure that your protobuf compiler and code generation tools support optional fields in proto3 syntax to avoid compatibility issues.


147-149: Consider potential recursive definitions in MapField.

The MapField includes a default_value of type map<string, Field>, which refers back to Field. Ensure that this recursive structure is intended and that serialization and deserialization handle it correctly to prevent runtime errors.

@danlarkin danlarkin force-pushed the danlarkin/duct-9356-account-creation-schema branch from 9ea719c to 13da073 Compare January 23, 2025 22:50
@@ -6,6 +6,7 @@ import "c1/connector/v2/asset.proto";
import "c1/connector/v2/resource.proto";
import "google/protobuf/any.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import "google/protobuf/timestamp.proto";

Copy link
Contributor

Choose a reason for hiding this comment

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

Guess this breaks lint sadge

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9ea719c and 13da073.

⛔ Files ignored due to path filters (1)
  • pb/c1/connector/v2/connector.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (6)
  • pb/c1/connector/v2/connector.pb.validate.go (2 hunks)
  • proto/c1/connector/v2/annotation_trait.proto (1 hunks)
  • proto/c1/connector/v2/connector.proto (3 hunks)
  • proto/c1/connector/v2/resource.proto (1 hunks)
  • proto/c1/connector/v2/ticket.proto (0 hunks)
  • proto/c1/connectorapi/baton/v1/baton.proto (6 hunks)
💤 Files with no reviewable changes (1)
  • proto/c1/connector/v2/ticket.proto
✅ Files skipped from review due to trivial changes (1)
  • proto/c1/connector/v2/annotation_trait.proto
🚧 Files skipped from review as they are similar to previous changes (2)
  • proto/c1/connector/v2/resource.proto
  • proto/c1/connectorapi/baton/v1/baton.proto
🧰 Additional context used
🪛 GitHub Check: buf-lint-and-breaking-change-detection
proto/c1/connector/v2/connector.proto

[failure] 9-9:
Import "google/protobuf/timestamp.proto" is unused.

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: go-test (1.22.x, windows-latest)
🔇 Additional comments (4)
pb/c1/connector/v2/connector.pb.validate.go (2)

557-584: Validation logic for AccountCreationSchema is correctly implemented.

The validation logic for the new AccountCreationSchema field in ConnectorMetadata correctly follows the established pattern, ensuring proper validation of embedded messages.


1816-2882: Validation methods for ConnectorAccountCreationSchema and associated fields are properly added.

The validation methods (Validate, ValidateAll, etc.) for ConnectorAccountCreationSchema and its nested messages (Field, StringField, BoolField, StringListField, IntField, MapField) are correctly implemented, ensuring comprehensive validation and error handling.

proto/c1/connector/v2/connector.proto (2)

49-49: Addition of account_creation_schema field to ConnectorMetadata is appropriate.

The new field account_creation_schema is correctly added to ConnectorMetadata with field number 9, extending the metadata structure to support account creation configurations.


111-151: Definition of ConnectorAccountCreationSchema and its nested messages is correct.

The messages ConnectorAccountCreationSchema, Field, StringField, BoolField, StringListField, IntField, and MapField are properly defined, following protobuf best practices. The use of field numbers, including starting the oneof fields at 100, is appropriate and helps maintain clarity in the message definitions.

@@ -6,6 +6,7 @@
import "c1/connector/v2/resource.proto";
import "google/protobuf/any.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove unused import google/protobuf/timestamp.proto.

The import of google/protobuf/timestamp.proto is unused in this file and can be removed to clean up the code.

Do you want me to generate a diff to remove the unused import?

🧰 Tools
🪛 GitHub Check: buf-lint-and-breaking-change-detection

[failure] 9-9:
Import "google/protobuf/timestamp.proto" is unused.

@danlarkin danlarkin merged commit 91efe04 into main Jan 23, 2025
4 checks passed
@danlarkin danlarkin deleted the danlarkin/duct-9356-account-creation-schema branch January 23, 2025 23:06
@coderabbitai coderabbitai bot mentioned this pull request Feb 25, 2025
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