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

fix: Fix next branch merge #194

Merged
merged 1 commit into from
Sep 23, 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
2 changes: 1 addition & 1 deletion api/__tests__/projects.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
jest.mock('../../http');
jest.mock('fs');
import { createReadStream } from 'fs';
import http from '../../http';
import { http } from '../../http';
import {
cancelStagedBuild,
checkCloneStatus,
Expand Down
4 changes: 2 additions & 2 deletions lib/trackUsage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ export async function trackUsage(
if (accountConfig && accountConfig.authType === 'personalaccesskey') {
logger.debug(i18n(`${i18nKey}.sendingEventAuthenticated`));
try {
const result: void = await http.post(accountId, {
await http.post(accountId, {
url: `${path}/authenticated`,
data: usageEvent,
resolveWithFullResponse: true,
});
return result;
return;
} catch (e) {
logger.debug(i18n(`${i18nKey}.retryingEventUnauthenticated`));
}
Expand Down
23 changes: 1 addition & 22 deletions models/HubSpotHttpError.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { isAxiosError, AxiosError } from 'axios';
import { isGatingError, isMissingScopeError } from '../errors';
import { HubSpotHttpErrorContext, ValidationError } from '../types/Error';
import { HttpMethod } from '../types/Api';
import { HTTP_METHOD_PREPOSITIONS, HTTP_METHOD_VERBS } from '../constants/api';
Expand Down Expand Up @@ -170,7 +169,6 @@ export class HubSpotHttpError<T = any> extends Error {
const i18nKey = 'errors.apiErrors';
const status = error.response?.status;
const method = error.config?.method as HttpMethod;
const { projectName } = context;

let messageDetail: string;

Expand Down Expand Up @@ -201,9 +199,6 @@ export class HubSpotHttpError<T = any> extends Error {
i18n(`${i18nKey}.unableToUpload`, { payload: context.payload })
);
}
const isProjectMissingScopeError =
isMissingScopeError(error) && !!projectName;
const isProjectGatingError = isGatingError(error) && !!projectName;

switch (status) {
case 400:
Expand All @@ -213,22 +208,6 @@ export class HubSpotHttpError<T = any> extends Error {
errorMessage.push(i18n(`${i18nKey}.codes.401`, { messageDetail }));
break;
case 403:
// TODO: Move projects specific errors to CLI in follow up
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 }));
}
break;
case 404:
errorMessage.push(i18n(`${i18nKey}.codes.404`, { messageDetail }));
Expand Down Expand Up @@ -259,7 +238,7 @@ export class HubSpotHttpError<T = any> extends Error {
if (error?.response?.data) {
const { message, errors } = error.response.data;

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

Expand Down
5 changes: 0 additions & 5 deletions models/__tests__/HubSpotHttpError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,6 @@ describe('models/HubSpotHttpError', () => {
message: 'The request was unauthorized.',
name: 'generates a 401 api status code error',
},
{
status: 403,
message: 'The request was forbidden.',
name: 'generates a 403 api status code error',
},
{
status: 404,
message: 'The request was not found.',
Expand Down
Loading