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

(WIP) Baton Actions #302

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

(WIP) Baton Actions #302

wants to merge 1 commit into from

Conversation

ggreer
Copy link
Contributor

@ggreer ggreer commented Feb 20, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a comprehensive action management service that supports executing actions, checking their status, retrieving schema details, and listing available schemas.
    • Enhanced input validation across action interactions to improve error handling and ensure clearer feedback on data inconsistencies.
    • Added detailed validation methods for various message types to ensure data integrity and comprehensive error reporting.

@ggreer ggreer requested a review from jirwin as a code owner February 20, 2025 04:02
Copy link

coderabbitai bot commented Feb 20, 2025

Warning

Rate limit exceeded

@ggreer has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 37 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 868fbc8 and baaed3e.

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

Walkthrough

These changes introduce robust validation logic for Protocol Buffers message types and add a new RPC service for action management. In two Go files, Validate and ValidateAll methods (along with custom multi-error and individual error types) are implemented for messages such as BatonAction, BatonActionSchema, and various ActionService-related requests and responses. Additionally, a new proto file defines an ActionService with four endpoints—Invoke, Status, GetSchema, and ListSchemas—supported by corresponding request/response messages and an enumeration for action statuses.

Changes

File Change Summary
pb/c1/.../action.pb.validate.go Added Validate/ValidateAll methods for BatonAction and BatonActionSchema; introduced custom multi-error and validation error types for robust error reporting.
pb/c1/.../connector/v2/action.pb.validate.go Implemented validation for various ActionService-related messages (Invoke, Status, GetSchema, ListSchemas requests/responses) with recursive checks and detailed error encapsulation.
proto/c1/.../action.proto Introduced new Protocol Buffers service, ActionService, with RPC endpoints (Invoke, Status, GetSchema, ListSchemas); defined associated request/response message types and an enum.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant AS as ActionService
    participant V as Validation Module

    C->>+AS: Send Invoke request (ActionServiceInvokeRequest)
    AS->>+V: Validate request (Validate/ValidateAll)
    V-->>-AS: Return validation result (error or success)
    AS->>AS: Process action if request is valid
    AS-->>-C: Return Invoke response (ActionServiceInvokeResponse)
Loading

Poem

Hop, hop, hop! I rate this commit fine,
With validations robust like carrots in a line.
New RPC hops into the service field bright,
Guiding actions with a joyful, swift byte!
CodeRabbit cheers with a twitch and a hop! 🐰🥕


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: 2

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

27-76: Messages design
The definitions for BatonActionSchema and the request/response messages look coherent. Each message has fields needed for the new ActionService. The usage of google.protobuf.Any for annotations is flexible but be mindful of potential overhead and type safety at runtime. Consider well-defined message types if feasible.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between afdcbcc and 5f51b2c.

⛔ Files ignored due to path filters (3)
  • pb/c1/action/v1/action.pb.go is excluded by !**/*.pb.go
  • pb/c1/connector/v2/action.pb.go is excluded by !**/*.pb.go
  • pb/c1/connector/v2/action_grpc.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (3)
  • pb/c1/action/v1/action.pb.validate.go (1 hunks)
  • pb/c1/connector/v2/action.pb.validate.go (1 hunks)
  • proto/c1/connector/v2/action.proto (1 hunks)
🧰 Additional context used
🪛 Buf (1.47.2)
proto/c1/connector/v2/action.proto

20-20: Enum value name "STATUS_UNKNOWN" should be prefixed with "BATON_ACTION_STATUS_".

(ENUM_VALUE_PREFIX)


20-20: Enum zero value name "STATUS_UNKNOWN" should be suffixed with "_UNSPECIFIED".

(ENUM_ZERO_VALUE_SUFFIX)


21-21: Enum value name "STATUS_PENDING" should be prefixed with "BATON_ACTION_STATUS_".

(ENUM_VALUE_PREFIX)


22-22: Enum value name "STATUS_RUNNING" should be prefixed with "BATON_ACTION_STATUS_".

(ENUM_VALUE_PREFIX)


23-23: Enum value name "STATUS_COMPLETE" should be prefixed with "BATON_ACTION_STATUS_".

(ENUM_VALUE_PREFIX)


24-24: Enum value name "STATUS_FAILED" should be prefixed with "BATON_ACTION_STATUS_".

(ENUM_VALUE_PREFIX)

🪛 GitHub Check: buf-lint-and-breaking-change-detection
proto/c1/connector/v2/action.proto

[failure] 9-9:
Files in package "c1.connector.v2" have multiple values "github.com/conductorone/baton-sdk/pb/c1/config/v1,github.com/conductorone/baton-sdk/pb/c1/connector/v2" for option "go_package" and all values must be equal.


[failure] 20-20:
Enum value name "STATUS_UNKNOWN" should be prefixed with "BATON_ACTION_STATUS_".


[failure] 20-20:
Enum zero value name "STATUS_UNKNOWN" should be suffixed with "_UNSPECIFIED".


[failure] 21-21:
Enum value name "STATUS_PENDING" should be prefixed with "BATON_ACTION_STATUS_".


[failure] 22-22:
Enum value name "STATUS_RUNNING" should be prefixed with "BATON_ACTION_STATUS_".


[failure] 23-23:
Enum value name "STATUS_COMPLETE" should be prefixed with "BATON_ACTION_STATUS_".


[failure] 24-24:
Enum value name "STATUS_FAILED" should be prefixed with "BATON_ACTION_STATUS_".

🔇 Additional comments (18)
pb/c1/action/v1/action.pb.validate.go (6)

1-36: Avoid over-customizing auto-generated files.
This file appears to be generated by protoc-gen-validate, so any manual modifications could be overwritten. Generally, application-specific logic is implemented in separate files, and generation is re-triggered upon changes to the proto definitions. Unless there's a pressing need for adjustments within the generated code, consider leaving these segments as-is.


38-96: Implementation of BatonAction validations looks correct.
The Validate, ValidateAll, and internal validate(all bool) methods properly detect embedded message errors and aggregate them when all is true. This structure is in line with standard protoc-gen-validate patterns. No concurrency, security, or performance issues are apparent here.


98-113: Multi-error wrapper for BatonAction.
The BatonActionMultiError is straightforward and aggregates multiple validation errors well. This is a standard approach for capturing batched validation feedback.


114-166: Structured individual validation error.
BatonActionValidationError effectively carries details about the problematic field, reason, and underlying cause. Such clarity is valuable when debugging validation failures.


168-297: Validation logic for BatonActionSchema.
These methods (and the embedded message checks for Arguments, Constraints, ReturnTypes) mirror the pattern used for BatonAction. Everything looks consistent, and errors are collected properly.


301-372: Multi-error and individual error types for BatonActionSchema.
Implementation is consistent with the rest of the file and appears functionally complete. No further recommendations for this auto-generated logic.

pb/c1/connector/v2/action.pb.validate.go (11)

1-37: Auto-generated validation boilerplate.
Similar to the previous file, these imports, variables, and initial comments appear to be standard protoc-gen-validate output. No action needed.


38-166: Mirroring BatonActionSchema validations for connector.
This block essentially replicates the BatonActionSchema validation logic in the v2 package context. It enforces the same rules for Arguments, Constraints, and ReturnTypes. Everything looks coherent.


244-337: ActionServiceInvokeRequest validations.
The function checks embedded message validation for Args and each item in Annotations. This approach is correct and thorough. No concurrency or data race concerns here.


338-410: InvokeRequest multi-error and validation error structures.
The multi-error approach for ActionServiceInvokeRequest is consistent. Fields such as field, reason, and cause provide clarity on failure points.


411-543: ActionServiceInvokeResponse validations.
Again, looks good. It checks Annotations array for embedded message compliance. No immediate improvements necessary.


552-683: ActionServiceStatusRequest validations.
Checks on Annotations mirror earlier patterns. No issues to resolve.


692-823: ActionServiceStatusResponse validations.
Similar pattern. The approach is consistent across request/response pairs.


833-963: ActionServiceGetSchemaRequest validations.
Validates Annotations array. The code is uniform with prior definitions; no improvements needed.


972-1134: ActionServiceGetSchemaResponse validations.
The loops for Arguments and ReturnTypes replicate the known approach of calling embedded Validate. Implementation is robust.


1143-1279: ActionServiceListSchemasRequest validations.
Similar structure. Recursively validates each item in Annotations.


1280-1418: ActionServiceListSchemasResponse validations.
Check of embedded BatonActionSchema items is well-implemented. Overall, the entire file is consistent and meets typical protoc-gen-validate conventions.

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

12-17: Service definitions:
The four RPCs (Invoke, Status, GetSchema, ListSchemas) match your new action management flows. The structure is straightforward, no immediate issues.

@ggreer ggreer force-pushed the ggreer/baton-actions branch 2 times, most recently from 42118f5 to 868fbc8 Compare February 20, 2025 04:44
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 (7)
pb/c1/connector/v2/action.pb.validate.go (7)

1-37: Auto-generated code notice.

This file is marked as auto-generated by protoc-gen-validate. Typically, such files should be excluded from manual edits and code reviews unless there’s a compelling reason to commit changes. Please confirm that committing this file is intentional to avoid potential merge conflicts and maintenance overhead.


38-243: No explicit validation rule for FunctionName.

The generated code indicates “no validation rules for FunctionName” in the BatonActionSchema. If you intend to enforce constraints (e.g., require a non-empty function name), consider specifying them in the proto definition so that protoc-gen-validate can generate the proper checks.


244-551: No validation rules for the 'Name' field in InvokeRequest.

ActionServiceInvokeRequest does not impose any constraints on the Name field. If you need strict rules (e.g., there must be at least one character), add them to the .proto file.


552-832: Check 'Name' and 'Id' fields in StatusRequest.

ActionServiceStatusRequest also omits explicit validation on Name or Id. If these fields must be non-empty or match certain patterns, consider adding constraints within the .proto file for more robust validation.


972-1142: Arrays of 'Arguments' and 'ReturnTypes' lack global constraints.

In ActionServiceGetSchemaResponse, each element is validated if it implements Validate, but the array size itself isn’t constrained. If you need a minimum or maximum length (e.g., at least one argument), define it in the proto to have protoc-gen-validate enforce it.


1143-1279: ListSchemasRequest fields lack explicit checks.

ActionServiceListSchemasRequest validates embedded messages but has no direct field-level constraints. Confirm whether certain fields need required or non-empty checks. If so, add them in the proto.


1280-1418: Repeated multi-error patterns.

Multiple messages (e.g., ActionServiceListSchemasResponse) include nearly identical multi-error and validation error logic. Although standard for auto-generated code, it leads to duplication. If you’d prefer a leaner approach, consider adjusting your protobuf or protoc-gen-validate plugin configuration to reduce repeated boilerplate.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5f51b2c and 868fbc8.

⛔ Files ignored due to path filters (3)
  • pb/c1/action/v1/action.pb.go is excluded by !**/*.pb.go
  • pb/c1/connector/v2/action.pb.go is excluded by !**/*.pb.go
  • pb/c1/connector/v2/action_grpc.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (3)
  • pb/c1/action/v1/action.pb.validate.go (1 hunks)
  • pb/c1/connector/v2/action.pb.validate.go (1 hunks)
  • proto/c1/connector/v2/action.proto (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • pb/c1/action/v1/action.pb.validate.go
  • proto/c1/connector/v2/action.proto
🔇 Additional comments (1)
pb/c1/connector/v2/action.pb.validate.go (1)

833-971: Missing validation constraints for 'Name' in GetSchemaRequest.

Like previous messages, ActionServiceGetSchemaRequest doesn’t enforce rules for the Name field. Verify whether this field should have any restrictions to maintain data integrity.

@ggreer ggreer force-pushed the ggreer/baton-actions branch from 868fbc8 to baaed3e Compare February 20, 2025 05:08
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