Skip to content

Handle proxy error #1757

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
merged 3 commits into from
Apr 9, 2025
Merged

Handle proxy error #1757

merged 3 commits into from
Apr 9, 2025

Conversation

Kitenite
Copy link
Contributor

@Kitenite Kitenite commented Apr 9, 2025

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Release
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes


Important

Refines error handling in LlmManager class and updates dev script in package.json.

  • Error Handling:
    • Refines error handling in LlmManager class in index.ts.
    • Removes getErrorMessage() method and consolidates error handling logic.
    • Handles RetryError, DOMException, and other errors with specific messages.
    • Ensures abortController is reset in finally block.
  • Logging:
    • Removes redundant console.error logging in index.ts.
  • Scripts:
    • Updates dev script in package.json to include --elide-lines=0.

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

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. Reviewed everything up to bae8eb2 in 1 minute and 54 seconds

More details
  • Looked at 94 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 8 drafted comments based on config settings.
1. apps/studio/electron/main/chat/index.ts:128
  • Draft comment:
    Potential risk: Directly logging and parsing error.error.lastError.responseBody without checking its existence. This could throw if the structure is different.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    The comment raises a valid concern about error handling. The code assumes a specific error structure which could fail. However, this is inside a try-catch block that will catch any JSON parse errors. The catch block handles parse failures by returning the stringified parse error. So while the suggestion would make the code more defensive, the existing error handling already covers this case.
    The code already has error handling for parse failures. The suggested change would add redundant null checks when failures are already caught.
    While the suggestion would make the code more defensive, the existing try-catch makes it unnecessary since parse failures are already handled gracefully.
    Delete this comment since the code already handles potential parsing errors appropriately through the surrounding try-catch block.
2. apps/studio/electron/main/chat/index.ts:129
  • Draft comment:
    Inconsistent error parsing: The catch block parses error.error.lastError.responseBody to access .error.message, while getErrorMessage() parses it expecting .error. Consider standardizing the error structure.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
3. apps/studio/electron/main/chat/index.ts:171
  • Draft comment:
    Using JSON.parse(error.error.lastError.responseBody).error without validation could lead to unexpected errors if responseBody format changes.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 30% vs. threshold = 50%
    The comment identifies a real potential issue - if the API response format changes, the code could throw additional errors. However, this is error handling code itself, and there's already a catch block (line 131) that would handle JSON parse failures. The code also has a fallback to return JSON.stringify(error) if parsing fails.
    The comment might be too nitpicky given this is error handling code with fallbacks. Also, we don't know if the error format is documented/guaranteed by the API provider.
    While there are fallbacks, adding validation could make the error handling more robust and explicit rather than relying on catch blocks.
    The comment identifies a real issue but the current error handling approach with fallbacks is reasonable. The suggested improvement would be nice-to-have but not critical.
4. package.json:30
  • Draft comment:
    Confirm that '--elide-lines=0' is intentional in the dev script and doesn't inadvertently expose too much logging.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    The comment violates one of our key rules - it's asking the author to "confirm" something, which falls under the category of verification questions we should avoid. Additionally, logging verbosity is typically a development-time concern that developers intentionally adjust for their needs. The fact that this is in the "dev" script (not production) suggests this was an intentional change to help with development.
    Perhaps this flag could expose sensitive information in logs that shouldn't be exposed, making it a security concern worth raising.
    Since this is only in the dev script (not production), logging verbosity is not a security concern - it's a local development tool that developers can adjust as needed.
    Delete the comment. It's asking for verification of an intentional change to a development script, which violates our rules about asking for confirmations.
5. apps/studio/electron/main/chat/index.ts:128
  • Draft comment:
    Accessing 'error.error.lastError.responseBody' without optional chaining may cause a runtime error if 'lastError' is undefined. Consider validating its existence or using optional chaining.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
    The code is already in a try-catch block that will catch any undefined property access errors. There's also a catch block specifically for parse errors. The error object structure seems to be expected in this context based on the surrounding code. Adding optional chaining here would be redundant given the existing error handling.
    The comment raises a valid concern about defensive programming. Optional chaining could prevent one specific type of runtime error.
    The existing error handling is already comprehensive - any undefined access would be caught and handled appropriately. Adding optional chaining here would add complexity without meaningful benefit.
    Delete this comment. The code already has robust error handling through try-catch blocks that would handle the case the comment is concerned about.
6. apps/studio/electron/main/chat/index.ts:129
  • Draft comment:
    Inconsistent error extraction: this line uses '.error.message' from the parsed JSON whereas getErrorMessage later returns the entire .error value. Consider unifying the extraction logic.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
7. package.json:30
  • Draft comment:
    Verify that the added '--elide-lines=0' flag in the 'dev' script is intentional and properly documented, as it may affect log output behavior.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    The comment is asking the PR author to verify their intention and ensure documentation, which violates the rules. It doesn't provide a specific suggestion or point out a clear issue with the code.
8. apps/studio/electron/main/chat/index.ts:1
  • Draft comment:
    PR title/description mismatch: The changes focus on handling proxy errors, but the PR description mentions onboarding docs improvements. Please update the PR details accordingly.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_0PLiHY3tJrTci4Fk


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.

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 6d96e40 in 1 minute and 35 seconds

More details
  • Looked at 56 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 drafted comments based on config settings.
1. apps/studio/electron/main/chat/index.ts:126
  • Draft comment:
    Good improvement handling RetryError. Consider adding a short comment noting that this branch is for proxy or retry-specific errors. Also, verify that parsed.error.message is always defined to avoid runtime errors.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
2. apps/studio/electron/main/chat/index.ts:159
  • Draft comment:
    Removal of getErrorMessage seems fine if its logic is no longer needed. Confirm that all error cases are now handled inline wherever errors occur.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
3. apps/studio/electron/main/chat/index.ts:126
  • Draft comment:
    Consider checking that error.error.lastError and its responseBody are defined before calling JSON.parse to avoid potential exceptions.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    The code is already using RetryError.isInstance() type guard which suggests it's a custom error class. This type guard likely ensures the error has the expected structure. The code is inside a try-catch block that will catch any JSON parse errors. Adding additional null checks would be redundant given the type guard and error handling.
    I could be wrong about what RetryError.isInstance() guarantees - maybe it doesn't ensure lastError.responseBody exists. The try-catch might make the code harder to debug by catching too broadly.
    The outer try-catch specifically handles parse errors and provides good error logging. RetryError is imported from 'ai' package suggesting it's a well-defined type. The code structure is intentional and robust.
    The comment should be deleted as the code already has appropriate error handling through type guards and try-catch blocks.
4. apps/studio/electron/main/chat/index.ts:154
  • Draft comment:
    The removal of the getErrorMessage helper is fine if it's not used elsewhere. Ensure that its functionality isn't needed in other error scenarios.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50%
    None
5. apps/studio/electron/main/chat/index.ts:1
  • Draft comment:
    The PR title indicates handling proxy errors, but the issue description mentions onboarding docs. Please confirm that the intended issue is being addressed.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50%
    None

Workflow ID: wflow_OpeQZ7X1uS790Zvo


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.

@Kitenite Kitenite merged commit 9c887ea into main Apr 9, 2025
@Kitenite Kitenite deleted the bugs/unknown-chat-error branch April 9, 2025 00:28
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 5a75c30 in 37 seconds

More details
  • Looked at 26 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. apps/studio/electron/main/chat/index.ts:135
  • Draft comment:
    Good addition to handle DOMException, returning a clear 'Request aborted' message. Consider ensuring that error.error is reliably defined before this check.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
2. apps/studio/electron/main/chat/index.ts:135
  • Draft comment:
    Added DOMException check for aborted requests is a good addition to handle proxy errors. Ensure this check covers all relevant proxy error scenarios and that no sensitive error details leak.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None

Workflow ID: wflow_QVygnzxIuFXqhu0D


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

ml-delaurier pushed a commit to ml-delaurier/nolook that referenced this pull request Apr 23, 2025
t1c1 pushed a commit to t1c1/onlookbotcodes that referenced this pull request Jun 5, 2025
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.

1 participant