Skip to content

Better handling for GFE errors#10313

Open
joehan wants to merge 1 commit intomainfrom
jh-gfe-errors
Open

Better handling for GFE errors#10313
joehan wants to merge 1 commit intomainfrom
jh-gfe-errors

Conversation

@joehan
Copy link
Copy Markdown
Member

@joehan joehan commented Apr 10, 2026

Description

Jetski took a crack at handling these errors that show up when you try to hit a API and your request gets blackholed.

Open to discussion on exactly how this should behave to best help users/developers understand and fix the issue.

@joehan joehan requested a review from inlined April 10, 2026 16:50
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a mechanism to detect and handle Google Front End (GFE) error pages by throwing a specific FirebaseError when the response contains characteristic HTML markers. The feedback provided addresses a typo and capitalization issue in the error message, suggests using a more robust regular expression for error detection to avoid brittleness with special characters, and ensures the associated unit tests are updated to match the corrected error string.

if (options.responseType === "json") {
const text = await res.text();
if (isGfeError(text)) {
throw new FirebaseError("the service you are calling doesnt exist or is misconfigured", { status: res.status });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The error message contains a typo ("doesnt") and should be properly capitalized for consistency with other user-facing errors in the codebase.

Suggested change
throw new FirebaseError("the service you are calling doesnt exist or is misconfigured", { status: res.status });
throw new FirebaseError("The service you are calling doesn't exist or is misconfigured.", { status: res.status });
References
  1. The repository style guide recommends using FirebaseError for user-facing errors; ensuring these messages are clear and correctly formatted maintains professional quality. (link)

}

function isGfeError(text: string): boolean {
return text.includes("That’s all we know.") && text.includes("<!DOCTYPE html>");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using a specific smart quote () in text.includes makes the detection brittle, as the response might use a standard apostrophe or different casing. A regular expression is more robust for identifying these error pages.

Suggested change
return text.includes("Thats all we know.") && text.includes("<!DOCTYPE html>");
return /That[']s all we know/i.test(text) && /<!DOCTYPE html>/i.test(text);

method: "GET",
path: "/path/to/foo",
});
await expect(r).to.eventually.be.rejectedWith(FirebaseError, "the service you are calling doesnt exist or is misconfigured");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Updating the test expectation to match the corrected error message.

Suggested change
await expect(r).to.eventually.be.rejectedWith(FirebaseError, "the service you are calling doesnt exist or is misconfigured");
await expect(r).to.eventually.be.rejectedWith(FirebaseError, "The service you are calling doesn't exist or is misconfigured.");

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.

2 participants