You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 20, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 20, 2025. It is now read-only.
err.code type changes from 'string' to 'number'. #1092
priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Is this a client library issue or a product issue?
This is the client library for . We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the Support page to reach the most relevant engineers.
Yes, it seems inconsistent that sometimes 'code' is a string and other times it's a 'number'. The types indicate it should be a string:
I'm assuming that the error returned is of type RequestError (correct me if that's wrong):
Hi there, thanks for submitting this bug! I can confirm that this is happening. Since GaxiosError expects code to be a string, it seems like this is indeed a bug.
@scschl we intend to address this issue, but all the fixes we could think of would be a breaking change for many of our libraries.
Are you able to workaround the issue today by running Number(err.code), and in the next major release for our libraries we will sort out these conversion issues?
priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
Activity
bcoe commentedon Oct 27, 2020
@scschl I would expect
error.codeto be anumber, is the problem that the types indicate that it's a string?scschl commentedon Oct 28, 2020
Yes, it seems inconsistent that sometimes 'code' is a string and other times it's a 'number'. The types indicate it should be a string:
I'm assuming that the error returned is of type RequestError (correct me if that's wrong):
export interface RequestError extends GaxiosError {
errors: Error[];
}
export declare class GaxiosError<T = any> extends Error {
code?: string;
response?: GaxiosResponse;
config: GaxiosOptions;
constructor(message: string, options: GaxiosOptions, response: GaxiosResponse);
}
scschl commentedon Oct 28, 2020
Also, if it's expected to be a number, why is it explicitly converted to a string if the status is >=400 ?
else if (res && res.status >= 400) {
// Consider all 4xx and 5xx responses errors.
err.message = body;
err.code = res.status.toString();
sofisl commentedon Apr 23, 2021
Hi there, thanks for submitting this bug! I can confirm that this is happening. Since
GaxiosErrorexpects code to be a string, it seems like this is indeed a bug.I've addressed it in #1165.
bcoe commentedon May 4, 2021
@scschl we intend to address this issue, but all the fixes we could think of would be a breaking change for many of our libraries.
Are you able to workaround the issue today by running
Number(err.code), and in the next major release for our libraries we will sort out these conversion issues?