Skip to content

Enhance error handling for 403 & 404 WebApi responses #714

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

Merged

Conversation

mawasile
Copy link
Contributor

This pull request introduces several changes to improve error handling in the API client by adding specific handlers for NotFound and Forbidden HTTP responses. These changes ensure that the client can provide more meaningful error messages when encountering these status codes. The main changes are grouped by theme as follows:

Error Handling Enhancements:

  • internal/api/client.go: Added HandleNotFoundResponse and HandleForbiddenResponse methods to handle 404 Not Found and 403 Forbidden HTTP responses respectively.

API Method Updates:

  • internal/services/authorization/api_user.go: Updated multiple methods (GetDataverseUsers, GetDataverseUserBySystemUserId, GetDataverseUserByAadObjectId, UpdateDataverseUser, DeleteDataverseUser, RemoveDataverseSecurityRoles, AddDataverseSecurityRoles, and GetDataverseSecurityRoles) to include 403 Forbidden and 404 Not Found in the list of acceptable status codes and to use the new error handling methods. [1] [2] [3] [4] [5] [6] [7] [8]

  • internal/services/data_record/api_data_record.go: Updated multiple methods (getEntityDefinition, GetDataRecordsByODataQuery, GetDataRecord, GetRelationData, GetTableSingularNameFromPlural, GetEntityAttributesDefinition, GetEntityRelationDefinitionInfo, ApplyDataRecord, DeleteDataRecord, and applyRelation) to include 403 Forbidden and 404 Not Found in the list of acceptable status codes and to use the new error handling methods. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]

…orbidden and 404 Not Found status codes across multiple API functions
@Copilot Copilot AI review requested due to automatic review settings April 15, 2025 15:14
@mawasile mawasile linked an issue Apr 15, 2025 that may be closed by this pull request
Copy link
Contributor

@Copilot 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.

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

internal/services/data_record/api_data_record.go:597

  • Using errors.New with a formatting verb (%w) is incorrect; replace it with fmt.Errorf to properly wrap the error.
return errors.New("error while deleting data record. %w")

github-actions[bot] added 2 commits April 15, 2025 18:54
@mawasile mawasile self-assigned this Apr 22, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…-_security_roles

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…-_security_roles
@mattdot mattdot merged commit 8021cc2 into main Apr 23, 2025
11 checks passed
@mattdot mattdot deleted the mawasile/701-error-client-error-when-reading-_security_roles branch April 23, 2025 19:06
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.

Error: Client error when reading _security_roles
2 participants