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

fix(chat): simplified error message coming from Cloudflare when using a VPN #7343

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ichim-david
Copy link
Collaborator

@ichim-david ichim-david commented Mar 5, 2025

Refs CODY-5032 improve error messages

Up to this point we were replying with a full blown html file all inside of an error box.
We now simplify the error message to make it easier for users to understand why they get a forbidden message from Cloudflare when they have a VPN enabled.

! I also removed the URL with the endpoint since this was something that was flagged in the ticket, replacing it
with simply "Sourcegraph".
I expect some need for tweaks both for this choice and for the message to be asked, to be changed if requested
as part of ticket review.

Test plan

Use a VPN and try to make a chat. Notice the difference in reply from receving
a full blown html page inside an error box to getting a simple error message.

Here is the end result that we would show to the user:
error-message-after-pull-request

@ichim-david ichim-david marked this pull request as draft March 7, 2025 07:32
When Cloudflare blocks a request (status code 403) due to a VPN or untrusted network, provide a more informative error message to the user. The message will instruct the user to try again without a VPN and includes the Cloudflare Ray ID for debugging.
We do this without waiting for the response to complete, as the error is already known.
This commit introduces a mechanism to transform client-side error messages before they are displayed to the user. This is achieved by:

-   Creating a `ClientErrorsTransformer` namespace that manages a pipeline of error transformers.
-   Implementing a `transform` function that iterates through registered transformers and applies them to the error message.
-   Registering a transformer `handleAUPError` that simplifies AUP (Acceptable Use Policy) error messages.
-   Applying the transformation in the `SourcegraphCompletionsClient` to simplify error messages.

This change improves the user experience by providing more user-friendly and informative error messages.
@ichim-david
Copy link
Collaborator Author

Added a transformer of client errors that are 200 responses instead of > 403 as it happens with the cloudflare VPN ban.

This allows me to treat as many cases as needed for the ticket, I already handled here the AUP policy if I try to make a query with a ban word.

AUP-fix

…error messages

This commit enhances error messages for Cloudflare 403 errors and other network errors by including the Sourcegraph Error ID (traceId). This addition aids in debugging and tracing issues within the Sourcegraph platform.

Specifically, the changes:

-   Add the Sourcegraph Error ID to the Cloudflare error message, providing a direct link to the relevant trace for easier debugging.
-   Include the Sourcegraph Error ID in other network error messages, improving the ability to track and diagnose network-related problems.
-   Conditionally append the Sourcegraph Error ID to the error message to avoid duplication.
…e ID and context deadline handling

This commit enhances the client-side error transformation mechanism to improve the user experience and aid in debugging.

Key changes include:

- **Transforms are now mutating** the error instead of
  acting as an error handler. This allows to chain potential
  transformations and ensures that the final error
  message is the result of all transformations.
-   **Trace ID Integration:** The `ClientErrorsTransformer` now receives the Sourcegraph trace ID, allowing error transformers to include it in error messages, improving traceability.
-   **Context Deadline Handling:** Added a transformer to provide a more user-friendly message when a context deadline is exceeded, guiding users to try again with a smaller context.
-   **Transformer Priority:** Introduced a priority system for error transformers, ensuring that the trace ID is appended last, preventing it from being overwritten by other transformations.
-   **Error Transformation in Client:** The `SourcegraphCompletionsClient` now passes the trace ID to the `ClientErrorsTransformer`.
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