Skip to content

fix: Improve readability of "enable this API" messages#10375

Open
kevmoo wants to merge 1 commit intofirebase:mainfrom
kevmoo:better_run_error
Open

fix: Improve readability of "enable this API" messages#10375
kevmoo wants to merge 1 commit intofirebase:mainfrom
kevmoo:better_run_error

Conversation

@kevmoo
Copy link
Copy Markdown
Contributor

@kevmoo kevmoo commented Apr 17, 2026

Fixes #10366

The existing bits get easily buried in the output. Make it super easy for the user to discover.

If cloud changes this text, the backup behavior is not catastrophic, either.

Fixes firebase#10366

The existing bits get easily buried in the output. Make it super easy for the user to discover.

If cloud changes this text, the backup behavior is not catastrophic, either.
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 modifies src/responseToError.ts to improve the readability of error messages by inserting double newlines before specific phrases related to API enablement. The review feedback suggests using a single global regular expression instead of multiple string-based replacements to ensure all occurrences are handled and to simplify the code logic.

Comment thread src/responseToError.ts
Comment on lines +43 to +47
errorMessage = errorMessage.replace("Enable it by visiting", "\n\nEnable it by visiting");
errorMessage = errorMessage.replace(
"If you enabled this API recently",
"\n\nIf you enabled this API recently",
);
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 current implementation using String.prototype.replace() with a string literal only replaces the first occurrence of the target text. While it is unlikely that these specific phrases appear multiple times in a single error message, using a global regular expression is more robust and ensures all occurrences are formatted as intended. Additionally, using a single regex with a capture group simplifies the logic and handles both phrases in one pass.

Suggested change
errorMessage = errorMessage.replace("Enable it by visiting", "\n\nEnable it by visiting");
errorMessage = errorMessage.replace(
"If you enabled this API recently",
"\n\nIf you enabled this API recently",
);
errorMessage = errorMessage.replace(/(Enable it by visiting|If you enabled this API recently)/g, "\n\n$1");

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.

Instructions to enable cloud run are buried in the output

2 participants