Skip to content

fix: prevent feature subgraphs from using other feature subgraphs as base subgraphs#2122

Merged
JivusAyrus merged 2 commits intomainfrom
suvij/eng-7757-a-feature-subgraph-should-not-be-a-base-subgraph
Aug 8, 2025
Merged

fix: prevent feature subgraphs from using other feature subgraphs as base subgraphs#2122
JivusAyrus merged 2 commits intomainfrom
suvij/eng-7757-a-feature-subgraph-should-not-be-a-base-subgraph

Conversation

@JivusAyrus
Copy link
Copy Markdown
Member

@JivusAyrus JivusAyrus commented Aug 7, 2025

Summary by CodeRabbit

  • New Features

    • Added validation to prevent creating or publishing a feature subgraph using another feature subgraph as its base. Users will now receive a clear error message if this is attempted.
  • Tests

    • Introduced new tests to ensure errors are properly returned when trying to use a feature subgraph as a base for another feature subgraph.
    • Refactored and reorganized existing test cases for clarity.

Checklist

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 7, 2025

Walkthrough

A validation was introduced to prevent feature subgraphs from being created or published with another feature subgraph as their base. This logic was added to both the creation and publishing flows. Corresponding tests were added and refactored to verify this restriction, including new error-handling scenarios.

Changes

Cohort / File(s) Change Summary
Feature Subgraph Validation Logic
controlplane/src/core/bufservices/subgraph/createFederatedSubgraph.ts, controlplane/src/core/bufservices/subgraph/publishFederatedSubgraph.ts
Added validation to disallow using a feature subgraph as the base for another feature subgraph during creation and publishing. Returns an error if this rule is violated.
Feature Subgraph Tests
controlplane/test/feature-subgraph/create-feature-subgraph.test.ts
Refactored and extended tests to check that feature subgraphs cannot use another feature subgraph as a base. Added explicit error case tests and minor formatting updates.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes


📜 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 bef9d04 and 5616d51.

📒 Files selected for processing (3)
  • controlplane/src/core/bufservices/subgraph/createFederatedSubgraph.ts (1 hunks)
  • controlplane/src/core/bufservices/subgraph/publishFederatedSubgraph.ts (1 hunks)
  • controlplane/test/feature-subgraph/create-feature-subgraph.test.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: build_push_image
  • GitHub Check: build_test
🔇 Additional comments (6)
controlplane/src/core/bufservices/subgraph/createFederatedSubgraph.ts (1)

197-206: LGTM! Proper validation to prevent feature subgraph chaining.

The validation correctly prevents feature subgraphs from using other feature subgraphs as their base, which aligns with the PR objectives. The error message is clear and the response structure is consistent with other error responses in the function.

controlplane/src/core/bufservices/subgraph/publishFederatedSubgraph.ts (1)

217-228: LGTM! Consistent validation logic for publishing flow.

The validation correctly prevents feature subgraphs from using other feature subgraphs as their base during the publishing process. The implementation is consistent with the creation flow, uses the same error message, and properly maintains all required response fields including proposalMatchMessage.

controlplane/test/feature-subgraph/create-feature-subgraph.test.ts (4)

330-363: Excellent test coverage for feature subgraph validation.

This test properly verifies that creating a feature subgraph with another feature subgraph as its base returns the expected error. The test setup is clear, and it correctly validates both the error code and the specific error message.


365-400: Comprehensive test for publishing scenario.

This test effectively covers the publishing flow validation, ensuring that the restriction applies when creating and publishing a feature subgraph in a single operation. The test follows the same pattern as the creation test and validates the same error conditions.


402-437: Good refactoring of role-based tests.

The refactoring to use test.each improves maintainability and reduces code duplication. The test logic remains the same while being more concise and easier to read.


316-316: Minor formatting improvements enhance consistency.

The addition of trailing commas and improved formatting of the RBAC evaluator creation enhances code consistency and readability.

Also applies to: 457-462

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch suvij/eng-7757-a-feature-subgraph-should-not-be-a-base-subgraph

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
  • 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 explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests 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.

Copy link
Copy Markdown
Contributor

@StarpTech StarpTech left a comment

Choose a reason for hiding this comment

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

LGTM

@JivusAyrus JivusAyrus merged commit b41a1d8 into main Aug 8, 2025
9 checks passed
@JivusAyrus JivusAyrus deleted the suvij/eng-7757-a-feature-subgraph-should-not-be-a-base-subgraph branch August 8, 2025 18:55
@coderabbitai coderabbitai Bot mentioned this pull request Aug 12, 2025
5 tasks
@Noroth Noroth mentioned this pull request Sep 30, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants