Skip to content

feat: dont allow custom and time partition together #1205

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

Conversation

nikhilsinhaparseable
Copy link
Contributor

@nikhilsinhaparseable nikhilsinhaparseable commented Feb 22, 2025

stream creation should fail if time and custom partition flags are set
also, allow only one field for custom partition

update stream should fail if user tries to set custom partition when time partition already exists

needs change in console as well
currently console allows 3 custom partition fields that need to be updated to allow 1 field

Summary by CodeRabbit

  • Bug Fixes
    • Stream partition validation now provides clearer error messages when both time and custom partitions are configured.
    • Custom partition settings are limited to one key to ensure a more straightforward configuration experience.

stream creation should fail if time and custom partition flags are set
also, allow only one field for custom partition

update stream should fail if user tries to set custom partition
when time partition already exists

needs change in console as well
currently console allows 3 custom partition fields
that need to be updated to allow 1 field
Copy link
Contributor

coderabbitai bot commented Feb 22, 2025

Walkthrough

The changes adjust the error handling for partition validation during stream creation. The code now returns a direct error if both a time partition and a custom partition are provided, rather than performing an intermediate list check. A new validation in the validate_and_update_custom_partition method ensures that a custom partition cannot be set when a time partition is already present. Additionally, the limit for allowed custom partition keys has been reduced from three to one, and error messages have been updated to reflect these changes.

Changes

File Change Summary
src/parseable/mod.rs - Simplified error handling: Directly returns an error if both time and custom partitions are set.
- Added check in validate_and_update_custom_partition for existing time partition.
- Updated custom partition key limit from 3 to 1 with corresponding error message.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant S as Stream Creation
    participant V as Validator

    U->>S: Request stream creation with time & custom partitions
    S->>V: Call validate_and_update_custom_partition()
    alt Both time & custom partitions provided
        V-->>S: Error: "Both partitions cannot be set simultaneously"
    else Custom partition keys exceed limit
        V-->>S: Error: "Custom partition key limit exceeded (max 1)"
    else
        V-->>S: Validation success
    end
    S-->>U: Return stream creation result or error
Loading

Poem

I'm just a bunny, hopping with glee,
Watching our code set errors free.
No more mixed up partitions in play,
Validation now leads the way.
With streamlined checks that never fail,
Our code hops on a perfect trail!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 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
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)
src/parseable/mod.rs (1)

827-836: Consider adding validation for empty or whitespace-only partition keys.

While the current implementation handles the number of partition keys correctly, it might be worth adding validation to ensure that partition keys are not empty or whitespace-only strings.

 pub fn validate_custom_partition(custom_partition: &str) -> Result<(), CreateStreamError> {
     let custom_partition_list = custom_partition.split(',').collect::<Vec<&str>>();
     if custom_partition_list.len() > 1 {
         return Err(CreateStreamError::Custom {
             msg: "Maximum 1 custom partition key is supported".to_string(),
             status: StatusCode::BAD_REQUEST,
         });
     }
+    if custom_partition_list.iter().any(|key| key.trim().is_empty()) {
+        return Err(CreateStreamError::Custom {
+            msg: "Custom partition key cannot be empty".to_string(),
+            status: StatusCode::BAD_REQUEST,
+        });
+    }
     Ok(())
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between db7c74a and ff8f098.

📒 Files selected for processing (1)
  • src/parseable/mod.rs (3 hunks)
🔇 Additional comments (3)
src/parseable/mod.rs (3)

470-475: LGTM! Clear error handling for partition validation.

The error handling correctly prevents setting both time and custom partitions simultaneously, which aligns with the PR objectives.


622-628: LGTM! Proper validation for stream updates.

The validation correctly prevents setting a custom partition when a time partition already exists, which aligns with the PR objectives.


829-832: LGTM! Clear restriction on custom partition keys.

The validation correctly limits custom partitioning to one field, which aligns with the PR objectives.

@nitisht nitisht merged commit 245ec54 into parseablehq:main Feb 23, 2025
14 checks passed
7h3cyb3rm0nk pushed a commit to 7h3cyb3rm0nk/parseable that referenced this pull request Feb 26, 2025
stream creation should fail if time and custom partition flags are set
also, allow only one field for custom partition

update stream should fail if user tries to set custom partition
when time partition already exists

needs change in console as well
currently console allows 3 custom partition fields
that need to be updated to allow 1 field
7h3cyb3rm0nk pushed a commit to 7h3cyb3rm0nk/parseable that referenced this pull request Feb 26, 2025
stream creation should fail if time and custom partition flags are set
also, allow only one field for custom partition

update stream should fail if user tries to set custom partition
when time partition already exists

needs change in console as well
currently console allows 3 custom partition fields
that need to be updated to allow 1 field
@coderabbitai coderabbitai bot mentioned this pull request Mar 24, 2025
3 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.

2 participants