Skip to content

🐛 Fix Offer creation redemptionCount error handling#28016

Open
AsishKumarDalal wants to merge 1 commit into
TryGhost:mainfrom
AsishKumarDalal:fix-offer-redemption-error
Open

🐛 Fix Offer creation redemptionCount error handling#28016
AsishKumarDalal wants to merge 1 commit into
TryGhost:mainfrom
AsishKumarDalal:fix-offer-redemption-error

Conversation

@AsishKumarDalal
Copy link
Copy Markdown

This PR fixes a TODO by properly throwing an InvalidOfferRedemptionCount error instead of the incorrect InvalidOfferCode when an Offer is created with a redemptionCount.

Changes

  • Added InvalidOfferRedemptionCount error class to domain/errors/index.js.
  • Updated offer.js to throw this new error when validating redemptionCount during offer creation.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0ec349da-1287-4f77-9be2-6e43ec6d36b2

📥 Commits

Reviewing files that changed from the base of the PR and between bd46a1c and 71105d4.

📒 Files selected for processing (2)
  • ghost/core/core/server/services/offers/domain/errors/index.js
  • ghost/core/core/server/services/offers/domain/models/offer.js

Walkthrough

This pull request introduces a new validation error class InvalidOfferRedemptionCount in the offers error module, extending the existing InvalidPropError base class. The new error is exported alongside other offer-related validation errors. The Offer.create method is updated to throw this new error type instead of InvalidOfferCode when validation fails during creation of a new offer with an explicit redemptionCount property.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: fixing error handling for redemptionCount validation during Offer creation, which matches the changeset.
Description check ✅ Passed The description accurately explains the changes made, including the new error class addition and the updated error thrown during offer creation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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