Skip to content

feat: Use FirstOrDefaultAsync for contract retrieval#209

Merged
kamilbaczek merged 3 commits intomainfrom
208-use-of-singleordefaultasync-may-throw-exception-when-multiple-contracts-exist-for-the-same-customer
Sep 2, 2025
Merged

feat: Use FirstOrDefaultAsync for contract retrieval#209
kamilbaczek merged 3 commits intomainfrom
208-use-of-singleordefaultasync-may-throw-exception-when-multiple-contracts-exist-for-the-same-customer

Conversation

@kamilbaczek
Copy link
Copy Markdown
Collaborator

Replaces SingleOrDefaultAsync with FirstOrDefaultAsync when fetching contracts by customer ID. This change prevents exceptions if multiple contracts exist for a customer and returns the most recently prepared contract.

Replaces SingleOrDefaultAsync with FirstOrDefaultAsync when fetching contracts by customer ID. This change prevents exceptions if multiple contracts exist for a customer and returns the most recently prepared contract.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates contract retrieval logic to handle scenarios where multiple contracts exist for a single customer. The change replaces SingleOrDefaultAsync with FirstOrDefaultAsync to prevent exceptions and return the most recently prepared contract based on the existing OrderByDescending sort.

  • Changes contract query method to use FirstOrDefaultAsync instead of SingleOrDefaultAsync

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.55%. Comparing base (24f85a7) to head (9dfa0f5).
Report is 373 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #209      +/-   ##
==========================================
+ Coverage   96.49%   96.55%   +0.05%     
==========================================
  Files          61       62       +1     
  Lines         542      551       +9     
  Branches        9        9              
==========================================
+ Hits          523      532       +9     
  Misses         16       16              
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@evolutionary-architecture evolutionary-architecture deleted a comment from Copilot AI Jul 19, 2025
@kamilbaczek kamilbaczek marked this pull request as draft July 19, 2025 20:20
@kamilbaczek kamilbaczek self-assigned this Aug 1, 2025
@kamilbaczek kamilbaczek marked this pull request as ready for review September 2, 2025 19:44
@kamilbaczek kamilbaczek merged commit 229dd3c into main Sep 2, 2025
2 checks passed
@kamilbaczek kamilbaczek deleted the 208-use-of-singleordefaultasync-may-throw-exception-when-multiple-contracts-exist-for-the-same-customer branch September 2, 2025 19:44
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.

Use of SingleOrDefaultAsync may throw exception when multiple contracts exist for the same customer

4 participants