Skip to content

fix: publishing plans with no ratecards - #2913

Merged
tothandras merged 1 commit into
mainfrom
refactor/productcatalog
May 28, 2025
Merged

tothandras merged 1 commit into
mainfrom
refactor/productcatalog

Conversation

@chrisgacsal

@chrisgacsal chrisgacsal commented May 28, 2025 •

Copy link
Copy Markdown
Collaborator

Overview

Fix publishin plan with no ratecards.

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation to ensure plan phases have at least one rate card and to warn about incompatible add-on assignments.
  • Tests
    • Updated tests to account for new validation warnings and to support ignoring non-critical issues during plan updates.

@coderabbitai

coderabbitai Bot commented May 28, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

New validation error codes and warning-level validation issues were introduced for plan phases without rate cards and plans with incompatible add-ons. Validation logic was updated to use these errors, error handling in plan publishing was unified to aggregate issues, and a test was updated to ignore non-critical issues for empty rate cards.

Changes

Files/Paths Change Summary
openmeter/productcatalog/errors.go Added new error codes and warning-level validation issues for missing rate cards and incompatible add-ons.
openmeter/productcatalog/phase.go Updated phase rate card validation to return a specific error if no rate cards are present.
openmeter/productcatalog/plan/service/plan.go Refactored plan publishing to aggregate validation errors for plans and add-ons using new error codes.
openmeter/productcatalog/plan/service/service_test.go Modified test to set IgnoreNonCriticalIssues when updating a plan with empty rate cards.

Possibly related PRs

  • feat: add plan-addon compatibility #2635: Introduces the PlanAddonAssignment type and its validation, including add-on compatibility checks, which relates directly to the new incompatible add-on validation error.
  • refactor(productcatalog): validation errors #2895: Refactors validation error handling by adding a common validationErrors field and standardizing error reporting, closely aligning with this PR's improvements to validation error structure and propagation.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (1.64.8)

Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2
Failed executing command with error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2


📜 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 69084be and 1b7454e.

📒 Files selected for processing (4)
  • openmeter/productcatalog/errors.go (1 hunks)
  • openmeter/productcatalog/phase.go (1 hunks)
  • openmeter/productcatalog/plan/service/plan.go (2 hunks)
  • openmeter/productcatalog/plan/service/service_test.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
openmeter/productcatalog/phase.go (2)
openmeter/productcatalog/ratecard.go (1)
  • RateCards (512-512)
openmeter/productcatalog/errors.go (1)
  • ErrPlanPhaseHasNoRateCards (439-444)
openmeter/productcatalog/errors.go (2)
pkg/models/errors.go (1)
  • ErrorCode (294-294)
pkg/models/validationissue.go (3)
  • NewValidationIssue (219-230)
  • WithFieldString (196-202)
  • WithWarningSeverity (214-216)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Test
  • GitHub Check: Quickstart
  • GitHub Check: Lint
  • GitHub Check: E2E
  • GitHub Check: Developer environment
  • GitHub Check: CI
  • GitHub Check: Analyze (go)
🔇 Additional comments (4)
openmeter/productcatalog/errors.go (1)

437-452: LGTM! Well-designed validation error codes.

The new validation error codes follow the established patterns in the codebase:

  • Consistent naming conventions
  • Appropriate warning severity for non-critical issues
  • Clear, descriptive error messages
  • Proper field context for the rate cards validation

These additions align well with the PR objective of fixing publishing plans with no rate cards by introducing specific validation issues.

openmeter/productcatalog/plan/service/service_test.go (1)

493-493: Appropriate test adjustment for non-critical validation.

Setting IgnoreNonCriticalIssues = true is the correct approach for testing the empty rate cards scenario. This allows the test to bypass the new warning-level validation (ErrPlanPhaseHasNoRateCards) introduced for empty rate cards, which aligns with the PR's goal of enabling plan publishing with no rate cards under specific conditions.

openmeter/productcatalog/phase.go (1)

132-134: Excellent validation enhancement.

The early return check for empty rate cards is well-implemented:

  • Uses the newly introduced ErrPlanPhaseHasNoRateCards validation error appropriately
  • Prevents unnecessary validation processing when no rate cards are present
  • Returns a warning-level error that can be bypassed when IgnoreNonCriticalIssues is enabled
  • Maintains the existing function behavior while adding the necessary validation

This directly addresses the PR objective of handling plans with no rate cards.

openmeter/productcatalog/plan/service/plan.go (1)

484-518: Excellent refactoring of error handling.

The consolidation of validation errors is a significant improvement:

Benefits:

  • Better user experience: Users now see all validation issues at once instead of having to fix them one by one
  • Consistent error reporting: Uses the new ErrPlanHasIncompatibleAddon validation error for standardized messaging
  • Comprehensive validation: Both plan and add-on validations are collected before returning

Implementation quality:

  • Error accumulation logic is correct and maintains all existing validation checks
  • Provides useful context in error messages (ID, key, version)
  • Proper use of errors.Join() for consolidation
  • Maintains the same validation rigor while improving error reporting

This change directly supports the PR objective by ensuring that all validation issues related to publishing plans are properly aggregated and reported.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
    • @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 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

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

@chrisgacsal chrisgacsal added the release-note/bug-fix Release note: Bug Fixes label May 28, 2025
@chrisgacsal
chrisgacsal force-pushed the refactor/productcatalog branch from 923b02b to 1b7454e Compare May 28, 2025 18:19
@chrisgacsal
chrisgacsal marked this pull request as ready for review May 28, 2025 18:20
@chrisgacsal
chrisgacsal requested a review from a team as a code owner May 28, 2025 18:20
@tothandras
tothandras merged commit e6e7c7e into main May 28, 2025
@tothandras
tothandras deleted the refactor/productcatalog branch May 28, 2025 18:32
@coderabbitai coderabbitai Bot mentioned this pull request Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants