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

Remove custom project 403 error handlers #169

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions errors/apiErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ export function getAxiosErrorWithContext(
): Error {
const status = error.response?.status;
const method = error.config?.method as HttpMethod;
const { projectName } = context;

let messageDetail: string;

Expand Down Expand Up @@ -161,9 +160,6 @@ export function getAxiosErrorWithContext(
i18n(`${i18nKey}.unableToUpload`, { payload: context.payload })
);
}
const isProjectMissingScopeError =
isMissingScopeError(error) && !!projectName;
const isProjectGatingError = isGatingError(error) && !!projectName;

switch (status) {
case 400:
Expand All @@ -173,21 +169,7 @@ export function getAxiosErrorWithContext(
errorMessage.push(i18n(`${i18nKey}.codes.401`, { messageDetail }));
break;
case 403:
if (isProjectMissingScopeError) {
errorMessage.push(
i18n(`${i18nKey}.codes.403ProjectMissingScope`, {
accountId: context.accountId || '',
})
);
} else if (isProjectGatingError) {
errorMessage.push(
i18n(`${i18nKey}.codes.403ProjectGating`, {
accountId: context.accountId || '',
})
);
} else {
errorMessage.push(i18n(`${i18nKey}.codes.403`, { messageDetail }));
}
errorMessage.push(i18n(`${i18nKey}.codes.403`, { messageDetail }));
break;
case 404:
errorMessage.push(i18n(`${i18nKey}.codes.404`, { messageDetail }));
Expand Down Expand Up @@ -216,7 +198,7 @@ export function getAxiosErrorWithContext(
if (error?.response?.data) {
const { message, errors } = error.response.data;

if (message && !isProjectMissingScopeError && !isProjectGatingError) {
if (message) {
errorMessage.push(message);
}

Expand Down
2 changes: 0 additions & 2 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,6 @@
"404": "The {{ messageDetail }} was not found.",
"429": "The {{ messageDetail }} surpassed the rate limit. Retry in one minute.",
"503": "The {{ messageDetail }} could not be handled at this time. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.",
"403ProjectMissingScope": "Couldn't run the project command because there are scopes missing in your production account. To update scopes, deactivate your current personal access key for {{ accountId }}, and generate a new one. Then run `hs auth` to update the CLI with the new key.",
"403ProjectGating": "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/product-updates/in-beta?update=13899236.",
"500Generic": "The {{ messageDetail }} failed due to a server error. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.",
"400Generic": "The {{ messageDetail }} failed due to a client error.",
"generic": "The {{ messageDetail }} failed."
Expand Down
1 change: 0 additions & 1 deletion types/Error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export type AxiosErrorContext = {
accountId?: number;
request?: string;
payload?: string;
projectName?: string;
};

export type OptionalError = BaseError | null | undefined;
Expand Down
Loading