-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
feat: update backend error #1089
feat: update backend error #1089
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -86,5 +89,6 @@ export class BackendClient { | |||
}); | |||
|
|||
setAxiosClientConfig(axiosClient.instance); | |||
this.instance = axiosClient.instance; |
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.
Redundant assignment of this.instance
. This is already assigned on line 39. Consider removing this duplicate assignment or add a comment explaining why it's needed twice.
const errorTypeFromBE = axiosError.response?.data?.error?.type; | ||
const errorMessage = axiosError.response?.data?.error?.message; | ||
|
||
const genericMessage = `${errorNameFromBE || predefinedError.message} ${errorTypeFromBE ? `- ${errorTypeFromBE}` : ""} on ${axiosError.config?.baseURL! + axiosError.config?.url!}`; |
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.
Consider adding null/undefined checks for axiosError.config?.baseURL
and axiosError.config?.url
. While the optional chaining helps prevent crashes, concatenating with undefined values could lead to "undefined" appearing in the error message.
This comment was generated by github-actions[bot]! JS SDK Coverage Report📊 Coverage report for JS SDK can be found at the following URL: 📁 Test report folder can be found at the following URL: |
expect(e.description).toBe("Not found"); | ||
expect(e.errorId).toBeDefined(); | ||
expect(e.name).toBe("ComposioError"); | ||
expect(e.possibleFix).toBe(e.possibleFix); |
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.
The test assertion expect(e.possibleFix).toBe(e.possibleFix)
is comparing a value with itself, which will always pass. This should probably be comparing against an expected value instead.
js/src/sdk/index.spec.ts
Outdated
|
||
try { | ||
await client.apps.list(); | ||
const apps = await client.apps.list(); | ||
console.log(apps); |
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.
The console.log(apps)
statement should be removed as it's not needed for the test and could clutter test output.
js/src/sdk/index.spec.ts
Outdated
expect(error.name).toBe("ComposioError"); | ||
expect(error.possibleFix).toBe(errorInfo.possibleFix); | ||
if (e instanceof ComposioError) { | ||
console.log(e); |
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.
Remove console.log(e)
from the test case. Debug logs should not be committed to the test suite.
Code Review SummaryOverall AssessmentThe changes improve error handling by better aligning with backend error responses and adding session tracking. The code quality is generally good, but there are a few areas that need attention. Strengths
Areas for Improvement
Rating: 7/10Good improvements to error handling, but needs cleanup of debug code and stronger validation. |
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.
👍 Looks good to me! Reviewed everything up to c19c9bf in 36 seconds
More details
- Looked at
374
lines of code in8
files - Skipped
0
files when reviewing. - Skipped posting
4
drafted comments based on config settings.
1. js/src/sdk/index.spec.ts:77
- Draft comment:
expect(error.message).toContain("InvalidRequestError");
- Reason this comment was not posted:
Comment looked like it was already resolved.
2. js/src/sdk/index.spec.ts:78
- Draft comment:
expect(error.message).toContain("InvalidRequestError");
- Reason this comment was not posted:
Marked as duplicate.
3. js/src/sdk/index.spec.ts:121
- Draft comment:
mock.onGet("/api/v1/apps").reply(500, { detail: "Internal Server Error" });
- Reason this comment was not posted:
Comment was on unchanged code.
4. js/src/sdk/index.spec.ts:122
- Draft comment:
error: {
type: "ServerError",
name: "InternalServerError",
message: "Internal Server Error",
},
- Reason this comment was not posted:
Marked as duplicate.
Workflow ID: wflow_ATOOL19T6OMPQiNN
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
Important
Improved error handling in the SDK with detailed messages, added session ID to context, and updated tests for new error formats.
getAPIErrorDetails()
informatter.ts
to provide more detailed error messages and descriptions.BE_STATUS_CODE_TO_SDK_ERROR_CODES
withAPI_TO_SDK_ERROR_CODE
inerror.ts
andconstants.ts
.handleAllError()
andthrowAPIError()
inerror.ts
.sessionId
toComposioSDKContext
incomposioContext.ts
.console.log
statements frombase.toolset.spec.ts
.index.spec.ts
to check for new error message formats.instance
property toBackendClient
inbackendClient.ts
for Axios instance management.This description was created by for c19c9bf. It will automatically update as commits are pushed.