Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial<T> for CommandResult<T> #5482

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

jrmccannon
Copy link
Contributor

📔 Objective

This is to allow for a partial success/failure result from a command that returns CommandResult<T>.

This introduces Error<T>.

public record Error<T>(string Message, T ErroredValue);

public record RecordNotFoundError<T>(string Message, T ErroredValue) : Error<T>(Message, ErroredValue)
{
    public const string Code = "Record Not Found";

    public RecordNotFoundError(T ErroredValue) : this(Code, ErroredValue)
    {

    }
}

public record InsufficientPermissionsError<T>(string Message, T ErroredValue) : Error<T>(Message, ErroredValue)
{
    public const string Code = "Insufficient Permissions";

    public InsufficientPermissionsError(T ErroredValue) : this(Code, ErroredValue)
    {

    }
}

Errors can be passed around instead of throwing exceptions for programmatic failures that could be due to anticipated issues with the request, current state, or system availability.

Partial<T> allows for successful objects to be returned alongside the failed objects. A failed representation is returned and can be used to pass the information onto the client.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link
Contributor

github-actions bot commented Mar 10, 2025

Logo
Checkmarx One – Scan Summary & Details490a398f-d3d6-4ed5-9671-3d921e015a20

New Issues (4)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
MEDIUM CSRF /src/Api/AdminConsole/Controllers/GroupsController.cs: 164
detailsMethod Put at line 164 of /src/Api/AdminConsole/Controllers/GroupsController.cs gets a parameter from a user request from model. This parameter val...
Attack Vector
MEDIUM CSRF /bitwarden_license/src/Scim/Controllers/v2/GroupsController.cs: 104
detailsMethod Patch at line 104 of /bitwarden_license/src/Scim/Controllers/v2/GroupsController.cs gets a parameter from a user request from model. This pa...
Attack Vector
MEDIUM CSRF /src/Api/AdminConsole/Public/Controllers/GroupsController.cs: 133
detailsMethod Put at line 133 of /src/Api/AdminConsole/Public/Controllers/GroupsController.cs gets a parameter from a user request from model. This parame...
Attack Vector
MEDIUM CSRF /bitwarden_license/src/Scim/Controllers/v2/GroupsController.cs: 94
detailsMethod Put at line 94 of /bitwarden_license/src/Scim/Controllers/v2/GroupsController.cs gets a parameter from a user request from model. This param...
Attack Vector
Fixed Issues (1)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
MEDIUM CSRF /src/Api/Billing/Controllers/AccountsController.cs: 142

Copy link

codecov bot commented Mar 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 44.38%. Comparing base (6e7c5b1) to head (42774ea).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5482      +/-   ##
==========================================
+ Coverage   44.36%   44.38%   +0.01%     
==========================================
  Files        1535     1535              
  Lines       70586    70601      +15     
  Branches     6315     6315              
==========================================
+ Hits        31318    31333      +15     
  Misses      37924    37924              
  Partials     1344     1344              

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jrmccannon jrmccannon marked this pull request as ready for review March 11, 2025 14:39
@jrmccannon jrmccannon requested a review from a team as a code owner March 11, 2025 14:43
@jrmccannon jrmccannon requested a review from JimmyVo16 March 11, 2025 14:43
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