Skip to content

Updated GiftService.getByToken to return null for missing gifts#27458

Merged
sagzy merged 1 commit into
mainfrom
gift-subscriptions/update-get-by-token
Apr 20, 2026
Merged

Updated GiftService.getByToken to return null for missing gifts#27458
sagzy merged 1 commit into
mainfrom
gift-subscriptions/update-get-by-token

Conversation

@sagzy
Copy link
Copy Markdown
Contributor

@sagzy sagzy commented Apr 20, 2026

no issue

Previously threw NotFoundError when the gift did not exist, forcing callers to wrap the call in a try/catch just to check existence

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 2026

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: 6b214012-0ac4-40cd-bbcb-19357224d8fe

📥 Commits

Reviewing files that changed from the base of the PR and between e7e19a5 and a9ff16a.

📒 Files selected for processing (2)
  • ghost/core/core/server/services/gifts/gift-service.ts
  • ghost/core/test/unit/server/services/gifts/gift-service.test.ts

Walkthrough

The GiftService.getByToken method signature was updated to return Promise<Gift | null> instead of Promise<Gift>. The previous implementation threw a NotFoundError when a gift was not found; this behavior was replaced with returning null. The method now directly returns the result from the gift repository without additional error handling. Corresponding unit tests were updated to expect null as a successful resolution instead of rejecting with a NotFoundError.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: updating GiftService.getByToken to return null instead of throwing an error for missing gifts.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation for the behavioral change from throwing NotFoundError to returning null.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch gift-subscriptions/update-get-by-token

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.

no issue

Previously threw NotFoundError when the gift did not exist, forcing
callers to wrap the call in a try/catch just to check existence
@sagzy sagzy force-pushed the gift-subscriptions/update-get-by-token branch from a803086 to a9ff16a Compare April 20, 2026 07:38
@sonarqubecloud
Copy link
Copy Markdown

@sagzy sagzy merged commit 511a438 into main Apr 20, 2026
43 checks passed
@sagzy sagzy deleted the gift-subscriptions/update-get-by-token branch April 20, 2026 11:52
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