Repository navigation
fix(hosting): name the function and regions in the wrong-region rewrite error - #11297
IzaakGough wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request improves the error messages shown when a Firebase Hosting rewrite targets a function in the wrong region. It updates findEndpointForRewrite to throw a detailed FirebaseError specifying the target region and listing the regions where the function was actually found, and updates the corresponding unit tests. The reviewer suggested a minor improvement to make the error message even more precise by outputting the actual region name instead of the generic phrase "that region" when only one region is available.
| throw new FirebaseError( | ||
| `Rewrite for function \`${id}\` in firebase.json targets region \`${region}\`, ` + | ||
| `but \`${id}\` was only found in ${regions}. Update the rewrite's \`region\` ` + | ||
| `in firebase.json to ${endpoints.length === 1 ? "that region" : "one of these regions"}.`, | ||
| ); |
There was a problem hiding this comment.
Instead of using the generic phrase "that region" when there is only one matching region, we can make the error message even more precise and actionable by outputting the actual region name (which is already formatted in the regions variable). This provides the user with a direct, copy-pasteable value for their firebase.json configuration.
Note: If you apply this suggestion, you will also need to update the corresponding unit tests in src/deploy/hosting/convertConfig.spec.ts to match the updated error message.
throw new FirebaseError(
`Rewrite for function \\\\`${id}\\\\\` in firebase.json targets region \\\\`${region}\\\\\`, ` +
`but \\\\`${id}\\\\\` was only found in ${regions}. Update the rewrite's \\\\`region\\\\\` ` +
`in firebase.json to ${endpoints.length === 1 ? regions : "one of these regions"}.`,
);References
- Error messages should clearly explain what failed and why; when actionable, provide concrete remediation guidance. (link)
Fixes #11289.
When a Hosting rewrite pointed at a function in the wrong region, the deploy failed with an error that did not say which function or which regions were involved.
The error now names the function, the region in the rewrite, and the regions where the function was found.
findEndpointForRewrite, next to the similar multi-region error, so the caller no longer needs its own wrong-region check.Tested with unit tests and a live
deploy --only hostingreproducing the issue. A correct-region deploy was not rerun live.