Skip to content

fix(billing): return empty array for discounts when no stripe id#1694

Merged
baktun14 merged 1 commit intomainfrom
fix/customer-discounts
Jul 16, 2025
Merged

fix(billing): return empty array for discounts when no stripe id#1694
baktun14 merged 1 commit intomainfrom
fix/customer-discounts

Conversation

@baktun14
Copy link
Contributor

@baktun14 baktun14 commented Jul 16, 2025

fixes: http://github.com/akash-network/console/issues/1676

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for retrieving customer discounts, ensuring users without a linked account receive an empty list instead of an error.

@baktun14 baktun14 requested a review from a team as a code owner July 16, 2025 19:03
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 16, 2025

Walkthrough

The update changes the error handling in the getCustomerDiscounts method of the StripeController. Instead of throwing a server error when a user lacks a stripeCustomerId, the method now returns an empty discounts array, ensuring a valid response without error.

Changes

File(s) Change Summary
.../controllers/stripe/stripe.controller.ts Modified error handling in getCustomerDiscounts to return an empty array if stripeCustomerId is missing, instead of throwing an error.

Poem

A bunny hopped through Stripe’s domain,
Where discounts sometimes wax and wane.
If no customer ID’s in sight,
No errors now—just calm delight.
An empty list, a gentle fix,
The code now hums, no need for tricks!

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.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-16T19_06_02_647Z-debug-0.log


📜 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 3709626 and b9660ca.

📒 Files selected for processing (1)
  • apps/api/src/billing/controllers/stripe/stripe.controller.ts (1 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). (2)
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
🔇 Additional comments (1)
apps/api/src/billing/controllers/stripe/stripe.controller.ts (1)

127-129: Confirmed safe empty‐array response in clients

Verified that all consumers already handle an empty discounts payload without errors:

  • HTTP SDK’s getCustomerDiscounts() simply unwraps whatever the API returns.
  • usePaymentDiscountsQuery (apps/deploy-web) uses response.discounts ?? [], and its tests cover both populated and missing discounts cases.
  • No front-end or SDK tests broke when the controller began returning { discounts: [] } for missing stripeCustomerId.

No breaking changes detected. You can proceed with this change.

• Consider addressing the broader inconsistency in missing-ID handling across the other StripeController methods in a follow-up.

✨ 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.

@codecov
Copy link

codecov bot commented Jul 16, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 72.08%. Comparing base (3709626) to head (b9660ca).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rc/billing/controllers/stripe/stripe.controller.ts 0.00% 1 Missing and 1 partial ⚠️

❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1694      +/-   ##
==========================================
- Coverage   72.11%   72.08%   -0.03%     
==========================================
  Files         597      597              
  Lines       13918    13919       +1     
  Branches     2375     2362      -13     
==========================================
- Hits        10037    10034       -3     
+ Misses       3648     3569      -79     
- Partials      233      316      +83     
Flag Coverage Δ *Carryforward flag
api 79.96% <0.00%> (-0.06%) ⬇️
deploy-web 56.32% <ø> (ø) Carriedforward from 3709626
notifications 87.25% <ø> (ø) Carriedforward from 3709626
provider-proxy 84.35% <ø> (ø) Carriedforward from 3709626

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...rc/billing/controllers/stripe/stripe.controller.ts 21.42% <0.00%> (-0.32%) ⬇️

... and 31 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@baktun14 baktun14 merged commit 19ec3c2 into main Jul 16, 2025
56 of 57 checks passed
@baktun14 baktun14 deleted the fix/customer-discounts branch July 16, 2025 20:09
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

Comments