-
Notifications
You must be signed in to change notification settings - Fork 8
"renamed-to-bad-request" #40
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -74,15 +74,14 @@ module.exports = class EntityTypes { | |||||||||||||||||||
| return resolve(entityData) | ||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||
| return reject({ | ||||||||||||||||||||
| status: error.status || HTTP_STATUS_CODE.internal_server_error.status, | ||||||||||||||||||||
| message: error.message || HTTP_STATUS_CODE.internal_server_error.message, | ||||||||||||||||||||
| status: error.status || HTTP_STATUS_CODE.bad_request.status, | ||||||||||||||||||||
| message: error.message || HTTP_STATUS_CODE.bad_request.message, | ||||||||||||||||||||
|
Comment on lines
+77
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reconsider changing database error status from 500 to 400. Database creation failures are typically server-side issues (connection problems, constraint violations, etc.) rather than client input problems. Using Consider implementing more specific error handling: } catch (error) {
- return reject({
- status: error.status || HTTP_STATUS_CODE.bad_request.status,
- message: error.message || HTTP_STATUS_CODE.bad_request.message,
- errorObject: error,
- })
+ return reject({
+ status: error.status || HTTP_STATUS_CODE.internal_server_error.status,
+ message: error.message || HTTP_STATUS_CODE.internal_server_error.message,
+ errorObject: error,
+ })
}Or implement more granular error classification based on error types. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| errorObject: error, | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| } | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| /** | ||||||||||||||||||||
| * find entityType documents. | ||||||||||||||||||||
| * @method | ||||||||||||||||||||
|
|
@@ -129,16 +128,14 @@ module.exports = class EntityTypes { | |||||||||||||||||||
| return resolve(document) | ||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||
| return reject({ | ||||||||||||||||||||
| status: error.status || HTTP_STATUS_CODE.internal_server_error.status, | ||||||||||||||||||||
| message: error.message || HTTP_STATUS_CODE.internal_server_error.message, | ||||||||||||||||||||
| status: error.status || HTTP_STATUS_CODE.bad_request.status, | ||||||||||||||||||||
| message: error.message || HTTP_STATUS_CODE.bad_request.message, | ||||||||||||||||||||
|
Comment on lines
+131
to
+132
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Database query failures should return 500, not 400. Similar to the create method, database query failures are typically server-side issues. A 400 status code suggests the client made an invalid request, which is misleading for database operation failures. 🤖 Prompt for AI Agents |
||||||||||||||||||||
| errorObject: error, | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| } | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| /** | ||||||||||||||||||||
| * Update entityTypes documents. | ||||||||||||||||||||
| * @method | ||||||||||||||||||||
|
|
@@ -161,8 +158,8 @@ module.exports = class EntityTypes { | |||||||||||||||||||
| return resolve(entityTypeData) | ||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||
| return reject({ | ||||||||||||||||||||
| status: error.status || HTTP_STATUS_CODE.internal_server_error.status, | ||||||||||||||||||||
| message: error.message || HTTP_STATUS_CODE.internal_server_error.message, | ||||||||||||||||||||
| status: error.status || HTTP_STATUS_CODE.bad_request.status, | ||||||||||||||||||||
| message: error.message || HTTP_STATUS_CODE.bad_request.message, | ||||||||||||||||||||
|
Comment on lines
+161
to
+162
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update operation failures should return 500, not 400. Database update failures are server-side issues and should maintain the 500 status code to properly communicate the nature of the error to API consumers. 🤖 Prompt for AI Agents |
||||||||||||||||||||
| errorObject: error, | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,8 +18,8 @@ module.exports = class userRoleExtension { | |
| return resolve(userRoleData) | ||
| } catch (error) { | ||
| return reject({ | ||
| status: error.status || HTTP_STATUS_CODE.internal_server_error.status, | ||
| message: error.message || HTTP_STATUS_CODE.internal_server_error.message, | ||
| status: error.status || HTTP_STATUS_CODE.bad_request.status, | ||
| message: error.message || HTTP_STATUS_CODE.bad_request.message, | ||
|
Comment on lines
+21
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Database operation errors should use 500 status code, not 400. All database operation failures in this class have been changed to return The affected methods ( Also applies to: 47-48, 103-104, 124-125 🤖 Prompt for AI Agents |
||
| errorObject: error, | ||
| }) | ||
| } | ||
|
|
@@ -44,8 +44,8 @@ module.exports = class userRoleExtension { | |
| return resolve(userData) | ||
| } catch (error) { | ||
| return reject({ | ||
| status: error.status || HTTP_STATUS_CODE.internal_server_error.status, | ||
| message: error.message || HTTP_STATUS_CODE.internal_server_error.message, | ||
| status: error.status || HTTP_STATUS_CODE.bad_request.status, | ||
| message: error.message || HTTP_STATUS_CODE.bad_request.message, | ||
| errorObject: error, | ||
| }) | ||
| } | ||
|
|
@@ -100,8 +100,8 @@ module.exports = class userRoleExtension { | |
| return resolve(userDocuments) | ||
| } catch (error) { | ||
| return reject({ | ||
| status: error.status || HTTP_STATUS_CODE.internal_server_error.status, | ||
| message: error.message || HTTP_STATUS_CODE.internal_server_error.message, | ||
| status: error.status || HTTP_STATUS_CODE.bad_request.status, | ||
| message: error.message || HTTP_STATUS_CODE.bad_request.message, | ||
| errorObject: error, | ||
| }) | ||
| } | ||
|
|
@@ -121,8 +121,8 @@ module.exports = class userRoleExtension { | |
| return resolve(userData) | ||
| } catch (error) { | ||
| return reject({ | ||
| status: error.status || HTTP_STATUS_CODE.internal_server_error.status, | ||
| message: error.message || HTTP_STATUS_CODE.internal_server_error.message, | ||
| status: error.status || HTTP_STATUS_CODE.bad_request.status, | ||
| message: error.message || HTTP_STATUS_CODE.bad_request.message, | ||
| errorObject: error, | ||
| }) | ||
| } | ||
|
|
||
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.
Systematic misclassification of database errors across all methods.
All six database operation methods have been changed to return
bad_request(400) instead ofinternal_server_error(500) for unclassified errors. This represents a fundamental misunderstanding of HTTP status codes:Database operation failures (connection issues, constraint violations, etc.) are server-side problems and should maintain 500 status codes.
Recommendation: Revert these changes and implement proper error classification:
Also applies to: 43-44, 67-68, 93-94, 147-148, 207-208
🤖 Prompt for AI Agents