-
Notifications
You must be signed in to change notification settings - Fork 0
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
[PM-13730] Return Policy object instead of NotFoundException #6
base: main
Are you sure you want to change the base?
[PM-13730] Return Policy object instead of NotFoundException #6
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
var policy = new AdminConsoleEntities.Policy(); | ||
policy.Type = (PolicyType)type; | ||
policy.Enabled = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider initializing the policy object with more meaningful default values, such as setting the OrganizationId.
if (!await _currentContext.ManagePolicies(orgIdGuid)) | ||
{ | ||
throw new NotFoundException(); | ||
return new PolicyResponseModel(policy); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Returning a default policy when the user doesn't have permission might mask authorization issues. Consider if a different response would be more appropriate for this case.
policy = await _policyRepository.GetByOrganizationIdTypeAsync(orgIdGuid, (PolicyType)type); | ||
if (policy == null) | ||
{ | ||
throw new NotFoundException(); | ||
return new PolicyResponseModel(policy); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: The default policy is overwritten here if found. Ensure this doesn't cause unexpected behavior if partial data is returned from the repository.
🎟️ Tracking
PM-13730
📔 Objective
This PR removes the thrown
NotFoundException
when policies are not found and returns a defaultPolicy
object with the sameType
sent in the request and theEnabled
value set tofalse
⏰ Reminders before review
🦮 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 changesGreptile Summary
This PR modifies the
PoliciesController
to return a defaultPolicy
object instead of throwing aNotFoundException
when a policy is not found or when the user lacks permission to manage policies.Get
method insrc/Api/AdminConsole/Controllers/PoliciesController.cs
to return a defaultPolicy
object withEnabled
set tofalse
NotFoundException
throw when user doesn't have permission to manage policiesNotFoundException
for error handling