Skip to content

Commit

Permalink
Merge pull request #169 from HubSpot/br-remove-custom-project-403-errors
Browse files Browse the repository at this point in the history
Remove custom project 403 error handlers
  • Loading branch information
brandenrodgers authored Sep 9, 2024
2 parents e495bd1 + 6a73fe2 commit 3ee1a31
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 23 deletions.
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

0 comments on commit 3ee1a31

Please sign in to comment.