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

feat: better error, handle 400 errors other format #928

Merged
merged 38 commits into from
Dec 9, 2024

Conversation

himanshu-dixit
Copy link
Collaborator

@himanshu-dixit himanshu-dixit commented Nov 29, 2024

  • Remove winston handling
  • Revert to original error throwing
  • better error format

P.S. - Need to be tested with cases before merging.


[!IMPORTANT]

Improved error handling by removing winston handling, reverting to original error throwing, and enhancing error format with new constants.

  • Error Handling​:- Removed winston error handling in logger.ts by setting handleExceptions and handleRejections to false.
    • Reverted to original error throwing using CEG.throwCustomError() in backendClient.ts and index.ts.

    • Improved error format by refactoring CEG in ceg.ts and introducing getBackendErrorResponseFormat() in backendErrorResponse.ts.

  • Error Constants​:- Moved error constants to constants.ts.
    • Added new error types like SERVER_UNAVAILABLE in constants.ts.
  • Telemetry​:- Added telemetry logging in telemetry/index.ts and telemetry/events.ts.
    • Introduced BatchProcessor in base/batchProcessor.ts for batching telemetry events.
  • Misc​:- Updated package.json version to 0.3.0-beta.2.
    • Added eslint.config.mjs and prettier.config.mjs for code formatting.

    • Updated typedoc.json to exclude test files.

This description was created by

<https://www.ellipsis.dev?ref=ComposioHQ%2Fcomposio&utm_source=github&utm_medium=referral%7Chttps://img.shields.io/badge/Ellipsis-blue?color=175173%7CEllipsis><sup> for b7522dd. It will automatically update as commits are pushed.


Important

Improves error handling and formatting, adds telemetry logging, and updates configuration for code formatting.

  • Error Handling:
    • Removed winston error handling in logger.ts by setting handleExceptions and handleRejections to false.
    • Reverted to original error throwing using CEG.throwCustomError() in backendClient.ts and index.ts.
    • Improved error format by refactoring CEG in ceg.ts and introducing getBackendErrorResponseFormat() in backendErrorResponse.ts.
  • Error Constants:
    • Moved error constants to constants.ts.
    • Added new error types like SERVER_UNAVAILABLE in constants.ts.
  • Telemetry:
    • Added telemetry logging in telemetry/index.ts and telemetry/events.ts.
    • Introduced BatchProcessor in base/batchProcessor.ts for batching telemetry events.
  • Misc:
    • Updated package.json version to 0.3.0-beta.2.
    • Added eslint.config.mjs and prettier.config.mjs for code formatting.
    • Updated typedoc.json to exclude test files.

This description was created by Ellipsis for 8ad6673. It will automatically update as commits are pushed.

Copy link

vercel bot commented Nov 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
composio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 9, 2024 10:16am

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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 0fc25c1 in 1 minute and 4 seconds

More details
  • Looked at 523 lines of code in 8 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_FnWrofcFnZpZuijr


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

github-actions bot commented Nov 29, 2024

This comment was generated by github-actions[bot]!

JS SDK Coverage Report

📊 Coverage report for JS SDK can be found at the following URL:
https://pub-92e668239ab84bfd80ee07d61e9d2f40.r2.dev/coverage-12233487281/coverage/index.html

📁 Test report folder can be found at the following URL:
https://pub-92e668239ab84bfd80ee07d61e9d2f40.r2.dev/html-report-12233487281/html-report/report.html

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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! Incremental review on 25d68c5 in 31 seconds

More details
  • Looked at 30 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. js/src/sdk/models/backendClient.spec.ts:22
  • Draft comment:
    The error message in the test does not match the error message in the constants file. It should be updated to match the message in constants.ts.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment seems speculative as it assumes the error message should match a constant from another file, but there is no evidence in the diff to support this. The diff only shows a change in the error message string, and there is no indication that it should match a constant. Without strong evidence, the comment should be removed.
    I might be missing context from other parts of the codebase that are not shown in the diff. The constants file might indeed have a relevant error message, but this is not evident from the diff provided.
    Given the rules, I should only consider the diff provided. Without evidence in the diff, I should not assume the existence of a relevant constant in another file.
    The comment should be deleted as it is speculative and not supported by evidence in the diff.

Workflow ID: wflow_6B7kVmBsYahq2864


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Incremental review on dfed375 in 1 minute and 23 seconds

More details
  • Looked at 724 lines of code in 17 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_ON9yTHaurRs6oAs4


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

const child = spawn('node', ['-e', `
const axios = require('axios');
// Send a POST request to the telemetry server with the reporting payload
axios.post('${info.url}', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The headers should be passed as a second argument to the axios.post method, not inside the data object.

Suggested change
axios.post('${info.url}', {
axios.post('${info.url}', ${JSON.stringify(info.reportingPayload)}, { headers: { 'Content-Type': 'application/json' } });

reportingPayload: Record<string, unknown>
}) {
// Create a new XMLHttpRequest object
const xhr = new XMLHttpRequest();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling for network errors and timeouts in the sendBrowserReq function to ensure robustness.

}

// Wait for logError to complete before continuing
logError({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider awaiting the logError call or handling the promise to avoid unhandled promise rejections.

}
}

processBatch() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling within the processBatch method to catch and handle any errors that occur during the execution of processBatchCallback.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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! Incremental review on 516e38e in 15 seconds

More details
  • Looked at 21 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. js/src/sdk/utils/error.ts:61
  • Draft comment:
    The cast to unknown is unnecessary when casting to AxiosError. You can directly cast axiosError to AxiosError.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The cast to unknown is unnecessary when casting to AxiosError.

Workflow ID: wflow_7OyhcCc9g1avW562


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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! Incremental review on e601a60 in 12 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. js/src/sdk/models/backendClient.spec.ts:22
  • Draft comment:
    Typo in the test description: 'should throw and error' should be 'should throw an error'.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The error message in the test has a typo in the word 'and'. It should be 'an'.

Workflow ID: wflow_BNv9QRFmMwWe6KR5


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -0,0 +1,9 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix: Remove empty line

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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! Incremental review on 624d764 in 47 seconds

More details
  • Looked at 10 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. js/src/sdk/utils/common.ts:3
  • Draft comment:
    Consider checking for null and arrays separately to avoid unintended stringification.
    return obj !== null && typeof obj === 'object' && !Array.isArray(obj) ? JSON.stringify(obj) : obj;
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_dB5r9ol1cbzq540r


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -60,7 +60,7 @@ export class Triggers {
});
return response.data as {status: string, triggerId: string};
} catch (error) {
throw CEG.handleError(error);
throw CEG.handleAllError(error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code contains a bug where throw CEG.handleAllError(error); is used in multiple catch blocks. However, CEG.handleAllError(error) itself throws an exception internally, which means that the throw statement attempts to throw undefined. This leads to runtime errors or unintended behavior, as the original error may be lost or result in unhandled exceptions. The throw keyword should be removed from these calls to allow CEG.handleAllError(error); to execute correctly. Additionally, within the handleAllError method, if isResponseNotPresent is true, the call to handleNonResponseAxiosError(error) always throws an error, making any subsequent code unreachable. This indicates a logical error that could lead to unexpected behavior.

Please check all the places.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead throw and throw. Added CEG.handleAllError(error) with argument shouldThrow, otherwise it returns error object.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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! Incremental review on 8ad6673 in 16 seconds

More details
  • Looked at 15 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. js/package.json:17
  • Draft comment:
    Consider using double quotes for consistency with other scripts.
    "prettier": "prettier --write \"src/**/*.ts\"",
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The change in the lint and prettier scripts to include quotes around the file paths is a good practice to handle paths with spaces. However, the change in the prettier script is not consistent with the rest of the scripts, which use double quotes. It's better to maintain consistency across the scripts.

Workflow ID: wflow_PXV6G6gTKRX9sIwl


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@himanshu-dixit himanshu-dixit merged commit e083b4f into master Dec 9, 2024
11 checks passed
@himanshu-dixit himanshu-dixit deleted the ft-handle-other-400-errors branch December 9, 2024 10:32
@himanshu-dixit himanshu-dixit restored the ft-handle-other-400-errors branch December 9, 2024 10:34
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.

3 participants