зеркало из
1
0
Форкнуть 0
Replaces the old custom "inner" and "innerError" concept from
the legacy app with the modern cause parameter.
This commit is contained in:
Jeff Wilcox 2023-04-06 18:10:22 -07:00
Родитель 6aeb236f11
Коммит 0f42e7f2cb
22 изменённых файлов: 164 добавлений и 191 удалений

Просмотреть файл

@ -104,7 +104,7 @@ router.get(
throw jsonError('This request does not exist or was created by another user', 400);
} catch (error) {
// Edge case: the team no longer exists.
if (error.innerError && error.innerError.innerError && error.innerError.innerError.statusCode == 404) {
if (error?.cause?.statusCode === 404 || error?.cause?.cause?.statusCode === 404) {
return closeOldRequest(true, request, req, res, next);
}
return next(jsonError(error));

Просмотреть файл

@ -189,15 +189,15 @@ export async function CreateRepository(
entrypoint,
},
});
if (error && error.innerError) {
const inner = error.innerError;
if (error?.cause) {
const cause = error.cause;
req.insights.trackException({
exception: inner,
exception: cause,
properties: {
event: 'ApiRepoCreateGitHubErrorInside',
message: inner && inner.message ? inner.message : inner,
status: inner && inner.status ? inner.status : '',
statusCode: inner && inner.statusCode ? inner.statusCode : '',
message: cause?.message || cause,
status: cause?.status || '',
statusCode: cause?.statusCode || '',
},
});
}

2
app.ts
Просмотреть файл

@ -130,7 +130,7 @@ app.runJob = async function (
console.error(`The job failed: ${jobError}`);
// by default, let's not show the whole inner error
const simpleError = { ...jobError };
simpleError?.innerError && delete simpleError.innerError;
simpleError?.cause && delete simpleError.cause;
console.dir(simpleError);
quitInTenSeconds(false);
if (options.insightsPrefix && app.providers.insights) {

Просмотреть файл

@ -72,11 +72,10 @@ module.exports = (graphApi) => {
}
templates = templatePackageData;
} catch (templatesNpmLoadError) {
const combinedError = new Error(
`Trouble loading npm package ${npmName} as configured in GITHUB_ORGANIZATIONS_TEMPLATES_PACKAGE_NAME: ${templatesNpmLoadError.toString()}`
throw new Error(
`Trouble loading npm package ${npmName} as configured in GITHUB_ORGANIZATIONS_TEMPLATES_PACKAGE_NAME: ${templatesNpmLoadError.toString()}`,
{ cause: templatesNpmLoadError }
);
combinedError.innerError = templatesNpmLoadError;
throw combinedError;
}
}

Просмотреть файл

@ -12,7 +12,6 @@ export type ConfigMail = {
from: string;
debug: {
[x: string]: any;
overrideRecipient: string;
isProductionRun: boolean;
testTargetCorporateIds: string;

Просмотреть файл

@ -3,10 +3,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
export interface InnerError extends Error {
inner?: Error;
}
export interface IReposError extends Error {
skipLog?: boolean;
status?: any; // status?: number;
@ -24,5 +20,4 @@ export interface IReposError extends Error {
link: string;
title: string;
};
innerError?: IReposError;
}

Просмотреть файл

@ -3,7 +3,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
// JOB: refresh repository data
// JOB 13: refresh repository data
// This is very similar to the query cache, but using proper Postgres type entities, and
// not being used by the app today.
@ -13,7 +13,7 @@
import throat from 'throat';
import app from '../app';
import { Organization, Repository, sortByRepositoryDate } from '../business';
import { Organization, sortByRepositoryDate } from '../business';
import { IRepositoryProvider, RepositoryEntity } from '../entities/repository';
import { IProviders, IReposJob, IReposJobResult } from '../interfaces';
import { ErrorHelper } from '../transitional';
@ -127,6 +127,7 @@ function setFields(repositoryProvider: IRepositoryProvider, repositoryEntity: Re
repositoryEntity.language = entity.language;
repositoryEntity.license = entity.license?.spdx_id;
repositoryEntity.fullName = entity.full_name;
repositoryEntity.organizationId = entity.organization?.id;
repositoryEntity.organizationLogin = entity.organization?.login;
repositoryEntity.name = entity.name;
repositoryEntity.networkCount = entity.network_count;

Просмотреть файл

@ -92,11 +92,9 @@ function addConfigPackage(paths: string[], applicationRoot: string, npmName: str
try {
packageInstance = require(npmName);
} catch (cannotRequire) {
const error: InnerError = new Error(
`While trying to identify configuration graphs, ${npmName} could not be required`
);
error.innerError = cannotRequire;
throw error;
throw new Error(`While trying to identify configuration graphs, ${npmName} could not be required`, {
cause: cannotRequire,
});
}
if (typeof packageInstance === 'string') {
root = packageInstance;
@ -142,9 +140,9 @@ function addAppConfigDirectory(
fs.statSync(dirPath);
paths.push(dirPath);
} catch (notFound) {
const error: InnerError = new Error(`The configuration graph directory ${dirPath} was not found. ${key}`);
error.innerError = notFound;
throw error;
throw new Error(`The configuration graph directory ${dirPath} was not found. ${key}`, {
cause: notFound,
});
}
}

Просмотреть файл

@ -55,11 +55,10 @@ function configurePackageEnvironments(
try {
environmentPackage = require(npmName);
} catch (packageRequireError) {
const packageMissing: InnerError = new Error(
`Unable to require the "${npmName}" environment package for the "${environment}" environment`
throw new Error(
`Unable to require the "${npmName}" environment package for the "${environment}" environment`,
{ cause: packageRequireError }
);
packageMissing.innerError = packageRequireError;
throw packageMissing;
}
if (!environmentPackage) {
continue;
@ -72,11 +71,10 @@ function configurePackageEnvironments(
values = environmentPackage(environment);
} catch (problemCalling) {
const asText = problemCalling.toString();
const error: InnerError = new Error(
`While calling the environment package "${npmName}" for the "${environment}" environment an error was thrown: ${asText}`
throw new Error(
`While calling the environment package "${npmName}" for the "${environment}" environment an error was thrown: ${asText}`,
{ cause: problemCalling }
);
error.innerError = problemCalling;
throw error;
}
} else if (typeof environmentPackage === 'object') {
values = environmentPackage;

Просмотреть файл

@ -21,12 +21,7 @@ const onlySupportedThirdPartyType = 'github';
import { randomUUID } from 'crypto';
import {
ICorporateLink,
ICorporateLinkExtended,
ICorporateLinkProperties,
InnerError,
} from '../../../interfaces';
import { ICorporateLink, ICorporateLinkExtended, ICorporateLinkProperties } from '../../../interfaces';
import { CorporateLinkPostgres } from './postgresLink';
import { PostgresPoolQueryAsync, PostgresPoolQuerySingleRowAsync } from '../../postgresHelpers';
@ -272,9 +267,7 @@ export class PostgresLinkProvider implements ILinkProvider {
return linkId;
} catch (error) {
if (error.message && error.message.includes('duplicate key value')) {
const ie: InnerError = new Error('A link already exists for the identity');
ie.inner = error;
error = ie;
throw new Error('A link already exists for the identity', { cause: error });
}
throw error;
}

Просмотреть файл

@ -491,9 +491,8 @@ export class TableLinkProvider implements ILinkProvider {
await this._tableClient.createEntity(entityObject);
} catch (insertError) {
if (ErrorHelper.IsConflict(insertError)) {
const error: IAlreadyLinkedError = new Error(entityAlreadyExistsErrorMessage);
const error: IAlreadyLinkedError = new Error(entityAlreadyExistsErrorMessage, { cause: insertError });
error.alreadyLinked = true;
error.innerError = insertError;
throw error;
}
throw insertError;

Просмотреть файл

@ -6,8 +6,6 @@
import Debug from 'debug';
const debug = Debug.debug('pg');
import { InnerError } from '../interfaces';
export function PostgresPoolQuerySingleRow(pool, sql: string, values: any[], callback) {
PostgresPoolQuery(pool, sql, values, (error, results) => {
if (error) {
@ -56,11 +54,11 @@ export function PostgresPoolQuery(pool, sql: string, values: any[], callback) {
client.query(sql, values, function (queryError, results) {
release();
if (queryError) {
const err: InnerError = new Error(
const err = new Error(
queryError.message /* Postgres provider never leaks SQL statements thankfully */ ||
'There was an error querying a database'
'There was an error querying a database',
{ cause: queryError }
);
err.inner = queryError;
if (queryError.position) {
err['position'] = queryError.position;
}

Просмотреть файл

@ -15,9 +15,10 @@ export default async function configureErrorRoutes(app: IReposApplication, initi
// production scenarios or if there is a risk of the
// error message leaking sensitive data.
app.use((req, res, next) => {
const error: IReposError = new Error('Application initialization error');
const error: IReposError = new Error('Application initialization error', {
cause: initializationError,
});
error.detailed = initializationError.message || null;
error.innerError = initializationError;
return next(error);
});
}

Просмотреть файл

@ -145,12 +145,10 @@ export default function SiteErrorHandler(err, req, res, next) {
if (err.stack && !isJson) {
console.error(err.stack);
}
if (err.innerError) {
const inner = err.innerError;
console.log('Inner: ' + inner.message);
if (inner.stack) {
console.log(inner.stack);
}
const cause = err.cause;
if (cause) {
console.log('Cause: ' + cause.message);
cause.stack && console.log(cause.stack);
}
}
// Bubble OAuth errors to the forefront... this is the rate limit scenario.

Просмотреть файл

@ -82,7 +82,7 @@ export async function AddOrganizationPermissionsToRequest(req: ReposAppRequest,
membershipStatus && membershipStatus.state ? membershipStatus.state : null;
return next();
} catch (getMembershipError) {
// if (getMembershipError && getMembershipError.innerError && getMembershipError.innerError.status === 404) {
// if (getMembershipError && getMembershipError.cause && getMembershipError.cause.status === 404) {
// getMembershipError = null;
// membershipStatus = null;
// }

Просмотреть файл

@ -72,13 +72,7 @@ import routeSslify from './sslify';
import middlewareIndex from '.';
import { ICacheHelper } from '../lib/caching';
import {
IApplicationProfile,
IProviders,
IReposApplication,
InnerError,
SiteConfiguration,
} from '../interfaces';
import { IApplicationProfile, IProviders, IReposApplication, SiteConfiguration } from '../interfaces';
import initializeRepositoryProvider from '../entities/repository';
import { tryGetImmutableStorageProvider } from '../lib/immutable';
@ -550,19 +544,20 @@ export function ConnectPostgresPool(postgresConfigSection: any): Promise<Postgre
);
});
// try connecting
pool.connect((err, client, release) => {
if (err) {
const poolError: InnerError = new Error(`There was a problem connecting to the Postgres server`);
poolError.inner = err;
pool.connect((cause, client, release) => {
if (cause) {
const poolError = new Error(`There was a problem connecting to the Postgres server`, {
cause,
});
return reject(poolError);
}
client.query('SELECT NOW()', (err, result) => {
release();
if (err) {
const poolQueryError: InnerError = new Error(
'There was a problem performing a test query to the Postgres server'
const poolQueryError = new Error(
'There was a problem performing a test query to the Postgres server',
{ cause: err }
);
poolQueryError.inner = err;
return reject(poolQueryError);
}
debug(

208
package-lock.json сгенерированный
Просмотреть файл

@ -23,7 +23,7 @@
"app-root-path": "3.1.0",
"applicationinsights": "2.5.1",
"async-prompt": "1.0.1",
"axios": "1.3.4",
"axios": "1.3.5",
"basic-auth": "2.0.1",
"body-parser": "1.20.2",
"color-contrast-checker": "2.1.0",
@ -77,7 +77,7 @@
"@types/express-session": "1.17.7",
"@types/jest": "29.5.0",
"@types/lodash": "4.14.192",
"@types/luxon": "3.2.0",
"@types/luxon": "3.3.0",
"@types/memory-cache": "0.2.2",
"@types/morgan": "1.9.4",
"@types/node": "18.15.11",
@ -92,8 +92,8 @@
"@types/semver": "7.3.13",
"@types/simple-oauth2": "5.0.4",
"@types/validator": "13.7.14",
"@typescript-eslint/eslint-plugin": "5.57.0",
"@typescript-eslint/parser": "5.57.0",
"@typescript-eslint/eslint-plugin": "5.57.1",
"@typescript-eslint/parser": "5.57.1",
"cspell": "6.31.1",
"eslint": "8.37.0",
"eslint-config-prettier": "8.8.0",
@ -105,7 +105,7 @@
"lint-staged": "13.2.0",
"markdownlint-cli2": "0.6.0",
"prettier": "2.8.7",
"ts-jest": "29.0.5",
"ts-jest": "29.1.0",
"ts-node": "10.9.1",
"typescript": "5.0.3"
},
@ -2853,9 +2853,9 @@
"integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw=="
},
"node_modules/@types/luxon": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.2.0.tgz",
"integrity": "sha512-lGmaGFoaXHuOLXFvuju2bfvZRqxAqkHPx9Y9IQdQABrinJJshJwfNCKV+u7rR3kJbiqfTF/NhOkcxxAFrObyaA==",
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.3.0.tgz",
"integrity": "sha512-uKRI5QORDnrGFYgcdAVnHvEIvEZ8noTpP/Bg+HeUzZghwinDlIS87DEenV5r1YoOF9G4x600YsUXLWZ19rmTmg==",
"dev": true
},
"node_modules/@types/memory-cache": {
@ -3075,15 +3075,15 @@
"dev": true
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.57.0.tgz",
"integrity": "sha512-itag0qpN6q2UMM6Xgk6xoHa0D0/P+M17THnr4SVgqn9Rgam5k/He33MA7/D7QoJcdMxHFyX7U9imaBonAX/6qA==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.57.1.tgz",
"integrity": "sha512-1MeobQkQ9tztuleT3v72XmY0XuKXVXusAhryoLuU5YZ+mXoYKZP9SQ7Flulh1NX4DTjpGTc2b/eMu4u7M7dhnQ==",
"dev": true,
"dependencies": {
"@eslint-community/regexpp": "^4.4.0",
"@typescript-eslint/scope-manager": "5.57.0",
"@typescript-eslint/type-utils": "5.57.0",
"@typescript-eslint/utils": "5.57.0",
"@typescript-eslint/scope-manager": "5.57.1",
"@typescript-eslint/type-utils": "5.57.1",
"@typescript-eslint/utils": "5.57.1",
"debug": "^4.3.4",
"grapheme-splitter": "^1.0.4",
"ignore": "^5.2.0",
@ -3109,14 +3109,14 @@
}
},
"node_modules/@typescript-eslint/parser": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.57.0.tgz",
"integrity": "sha512-orrduvpWYkgLCyAdNtR1QIWovcNZlEm6yL8nwH/eTxWLd8gsP+25pdLHYzL2QdkqrieaDwLpytHqycncv0woUQ==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.57.1.tgz",
"integrity": "sha512-hlA0BLeVSA/wBPKdPGxoVr9Pp6GutGoY380FEhbVi0Ph4WNe8kLvqIRx76RSQt1lynZKfrXKs0/XeEk4zZycuA==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.57.0",
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/typescript-estree": "5.57.0",
"@typescript-eslint/scope-manager": "5.57.1",
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/typescript-estree": "5.57.1",
"debug": "^4.3.4"
},
"engines": {
@ -3136,13 +3136,13 @@
}
},
"node_modules/@typescript-eslint/scope-manager": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.57.0.tgz",
"integrity": "sha512-NANBNOQvllPlizl9LatX8+MHi7bx7WGIWYjPHDmQe5Si/0YEYfxSljJpoTyTWFTgRy3X8gLYSE4xQ2U+aCozSw==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.57.1.tgz",
"integrity": "sha512-N/RrBwEUKMIYxSKl0oDK5sFVHd6VI7p9K5MyUlVYAY6dyNb/wHUqndkTd3XhpGlXgnQsBkRZuu4f9kAHghvgPw==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/visitor-keys": "5.57.0"
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/visitor-keys": "5.57.1"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -3153,13 +3153,13 @@
}
},
"node_modules/@typescript-eslint/type-utils": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.57.0.tgz",
"integrity": "sha512-kxXoq9zOTbvqzLbdNKy1yFrxLC6GDJFE2Yuo3KqSwTmDOFjUGeWSakgoXT864WcK5/NAJkkONCiKb1ddsqhLXQ==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.57.1.tgz",
"integrity": "sha512-/RIPQyx60Pt6ga86hKXesXkJ2WOS4UemFrmmq/7eOyiYjYv/MUSHPlkhU6k9T9W1ytnTJueqASW+wOmW4KrViw==",
"dev": true,
"dependencies": {
"@typescript-eslint/typescript-estree": "5.57.0",
"@typescript-eslint/utils": "5.57.0",
"@typescript-eslint/typescript-estree": "5.57.1",
"@typescript-eslint/utils": "5.57.1",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
},
@ -3180,9 +3180,9 @@
}
},
"node_modules/@typescript-eslint/types": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.57.0.tgz",
"integrity": "sha512-mxsod+aZRSyLT+jiqHw1KK6xrANm19/+VFALVFP5qa/aiJnlP38qpyaTd0fEKhWvQk6YeNZ5LGwI1pDpBRBhtQ==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.57.1.tgz",
"integrity": "sha512-bSs4LOgyV3bJ08F5RDqO2KXqg3WAdwHCu06zOqcQ6vqbTJizyBhuh1o1ImC69X4bV2g1OJxbH71PJqiO7Y1RuA==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -3193,13 +3193,13 @@
}
},
"node_modules/@typescript-eslint/typescript-estree": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.57.0.tgz",
"integrity": "sha512-LTzQ23TV82KpO8HPnWuxM2V7ieXW8O142I7hQTxWIHDcCEIjtkat6H96PFkYBQqGFLW/G/eVVOB9Z8rcvdY/Vw==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.57.1.tgz",
"integrity": "sha512-A2MZqD8gNT0qHKbk2wRspg7cHbCDCk2tcqt6ScCFLr5Ru8cn+TCfM786DjPhqwseiS+PrYwcXht5ztpEQ6TFTw==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/visitor-keys": "5.57.0",
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/visitor-keys": "5.57.1",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@ -3220,17 +3220,17 @@
}
},
"node_modules/@typescript-eslint/utils": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.57.0.tgz",
"integrity": "sha512-ps/4WohXV7C+LTSgAL5CApxvxbMkl9B9AUZRtnEFonpIxZDIT7wC1xfvuJONMidrkB9scs4zhtRyIwHh4+18kw==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.57.1.tgz",
"integrity": "sha512-kN6vzzf9NkEtawECqze6v99LtmDiUJCVpvieTFA1uL7/jDghiJGubGZ5csicYHU1Xoqb3oH/R5cN5df6W41Nfg==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@types/json-schema": "^7.0.9",
"@types/semver": "^7.3.12",
"@typescript-eslint/scope-manager": "5.57.0",
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/typescript-estree": "5.57.0",
"@typescript-eslint/scope-manager": "5.57.1",
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/typescript-estree": "5.57.1",
"eslint-scope": "^5.1.1",
"semver": "^7.3.7"
},
@ -3246,12 +3246,12 @@
}
},
"node_modules/@typescript-eslint/visitor-keys": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.57.0.tgz",
"integrity": "sha512-ery2g3k0hv5BLiKpPuwYt9KBkAp2ugT6VvyShXdLOkax895EC55sP0Tx5L0fZaQueiK3fBLvHVvEl3jFS5ia+g==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.57.1.tgz",
"integrity": "sha512-RjQrAniDU0CEk5r7iphkm731zKlFiUjvcBS2yHAg8WWqFMCaCrD0rKEVOMUyMMcbGPZ0bPp56srkGWrgfZqLRA==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/types": "5.57.1",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
@ -3556,9 +3556,9 @@
}
},
"node_modules/axios": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz",
"integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==",
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.3.5.tgz",
"integrity": "sha512-glL/PvG/E+xCWwV8S6nCHcrfg1exGx7vxyUIivIA1iL7BIh6bePylCfVHwp6k13ao7SATxB6imau2kqY+I67kw==",
"dependencies": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
@ -10332,9 +10332,9 @@
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
"node_modules/ts-jest": {
"version": "29.0.5",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.0.5.tgz",
"integrity": "sha512-PL3UciSgIpQ7f6XjVOmbi96vmDHUqAyqDr8YxzopDqX3kfgYtX1cuNeBjP+L9sFXi6nzsGGA6R3fP3DDDJyrxA==",
"version": "29.1.0",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.0.tgz",
"integrity": "sha512-ZhNr7Z4PcYa+JjMl62ir+zPiNJfXJN6E8hSLnaUKhOgqcn8vb3e537cpkd0FuAfRK3sR1LSqM1MOhliXNgOFPA==",
"dev": true,
"dependencies": {
"bs-logger": "0.x",
@ -10357,7 +10357,7 @@
"@jest/types": "^29.0.0",
"babel-jest": "^29.0.0",
"jest": "^29.0.0",
"typescript": ">=4.3"
"typescript": ">=4.3 <6"
},
"peerDependenciesMeta": {
"@babel/core": {
@ -13323,9 +13323,9 @@
"integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw=="
},
"@types/luxon": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.2.0.tgz",
"integrity": "sha512-lGmaGFoaXHuOLXFvuju2bfvZRqxAqkHPx9Y9IQdQABrinJJshJwfNCKV+u7rR3kJbiqfTF/NhOkcxxAFrObyaA==",
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.3.0.tgz",
"integrity": "sha512-uKRI5QORDnrGFYgcdAVnHvEIvEZ8noTpP/Bg+HeUzZghwinDlIS87DEenV5r1YoOF9G4x600YsUXLWZ19rmTmg==",
"dev": true
},
"@types/memory-cache": {
@ -13544,15 +13544,15 @@
"dev": true
},
"@typescript-eslint/eslint-plugin": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.57.0.tgz",
"integrity": "sha512-itag0qpN6q2UMM6Xgk6xoHa0D0/P+M17THnr4SVgqn9Rgam5k/He33MA7/D7QoJcdMxHFyX7U9imaBonAX/6qA==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.57.1.tgz",
"integrity": "sha512-1MeobQkQ9tztuleT3v72XmY0XuKXVXusAhryoLuU5YZ+mXoYKZP9SQ7Flulh1NX4DTjpGTc2b/eMu4u7M7dhnQ==",
"dev": true,
"requires": {
"@eslint-community/regexpp": "^4.4.0",
"@typescript-eslint/scope-manager": "5.57.0",
"@typescript-eslint/type-utils": "5.57.0",
"@typescript-eslint/utils": "5.57.0",
"@typescript-eslint/scope-manager": "5.57.1",
"@typescript-eslint/type-utils": "5.57.1",
"@typescript-eslint/utils": "5.57.1",
"debug": "^4.3.4",
"grapheme-splitter": "^1.0.4",
"ignore": "^5.2.0",
@ -13562,53 +13562,53 @@
}
},
"@typescript-eslint/parser": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.57.0.tgz",
"integrity": "sha512-orrduvpWYkgLCyAdNtR1QIWovcNZlEm6yL8nwH/eTxWLd8gsP+25pdLHYzL2QdkqrieaDwLpytHqycncv0woUQ==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.57.1.tgz",
"integrity": "sha512-hlA0BLeVSA/wBPKdPGxoVr9Pp6GutGoY380FEhbVi0Ph4WNe8kLvqIRx76RSQt1lynZKfrXKs0/XeEk4zZycuA==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.57.0",
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/typescript-estree": "5.57.0",
"@typescript-eslint/scope-manager": "5.57.1",
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/typescript-estree": "5.57.1",
"debug": "^4.3.4"
}
},
"@typescript-eslint/scope-manager": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.57.0.tgz",
"integrity": "sha512-NANBNOQvllPlizl9LatX8+MHi7bx7WGIWYjPHDmQe5Si/0YEYfxSljJpoTyTWFTgRy3X8gLYSE4xQ2U+aCozSw==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.57.1.tgz",
"integrity": "sha512-N/RrBwEUKMIYxSKl0oDK5sFVHd6VI7p9K5MyUlVYAY6dyNb/wHUqndkTd3XhpGlXgnQsBkRZuu4f9kAHghvgPw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/visitor-keys": "5.57.0"
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/visitor-keys": "5.57.1"
}
},
"@typescript-eslint/type-utils": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.57.0.tgz",
"integrity": "sha512-kxXoq9zOTbvqzLbdNKy1yFrxLC6GDJFE2Yuo3KqSwTmDOFjUGeWSakgoXT864WcK5/NAJkkONCiKb1ddsqhLXQ==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.57.1.tgz",
"integrity": "sha512-/RIPQyx60Pt6ga86hKXesXkJ2WOS4UemFrmmq/7eOyiYjYv/MUSHPlkhU6k9T9W1ytnTJueqASW+wOmW4KrViw==",
"dev": true,
"requires": {
"@typescript-eslint/typescript-estree": "5.57.0",
"@typescript-eslint/utils": "5.57.0",
"@typescript-eslint/typescript-estree": "5.57.1",
"@typescript-eslint/utils": "5.57.1",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/types": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.57.0.tgz",
"integrity": "sha512-mxsod+aZRSyLT+jiqHw1KK6xrANm19/+VFALVFP5qa/aiJnlP38qpyaTd0fEKhWvQk6YeNZ5LGwI1pDpBRBhtQ==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.57.1.tgz",
"integrity": "sha512-bSs4LOgyV3bJ08F5RDqO2KXqg3WAdwHCu06zOqcQ6vqbTJizyBhuh1o1ImC69X4bV2g1OJxbH71PJqiO7Y1RuA==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.57.0.tgz",
"integrity": "sha512-LTzQ23TV82KpO8HPnWuxM2V7ieXW8O142I7hQTxWIHDcCEIjtkat6H96PFkYBQqGFLW/G/eVVOB9Z8rcvdY/Vw==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.57.1.tgz",
"integrity": "sha512-A2MZqD8gNT0qHKbk2wRspg7cHbCDCk2tcqt6ScCFLr5Ru8cn+TCfM786DjPhqwseiS+PrYwcXht5ztpEQ6TFTw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/visitor-keys": "5.57.0",
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/visitor-keys": "5.57.1",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@ -13617,28 +13617,28 @@
}
},
"@typescript-eslint/utils": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.57.0.tgz",
"integrity": "sha512-ps/4WohXV7C+LTSgAL5CApxvxbMkl9B9AUZRtnEFonpIxZDIT7wC1xfvuJONMidrkB9scs4zhtRyIwHh4+18kw==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.57.1.tgz",
"integrity": "sha512-kN6vzzf9NkEtawECqze6v99LtmDiUJCVpvieTFA1uL7/jDghiJGubGZ5csicYHU1Xoqb3oH/R5cN5df6W41Nfg==",
"dev": true,
"requires": {
"@eslint-community/eslint-utils": "^4.2.0",
"@types/json-schema": "^7.0.9",
"@types/semver": "^7.3.12",
"@typescript-eslint/scope-manager": "5.57.0",
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/typescript-estree": "5.57.0",
"@typescript-eslint/scope-manager": "5.57.1",
"@typescript-eslint/types": "5.57.1",
"@typescript-eslint/typescript-estree": "5.57.1",
"eslint-scope": "^5.1.1",
"semver": "^7.3.7"
}
},
"@typescript-eslint/visitor-keys": {
"version": "5.57.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.57.0.tgz",
"integrity": "sha512-ery2g3k0hv5BLiKpPuwYt9KBkAp2ugT6VvyShXdLOkax895EC55sP0Tx5L0fZaQueiK3fBLvHVvEl3jFS5ia+g==",
"version": "5.57.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.57.1.tgz",
"integrity": "sha512-RjQrAniDU0CEk5r7iphkm731zKlFiUjvcBS2yHAg8WWqFMCaCrD0rKEVOMUyMMcbGPZ0bPp56srkGWrgfZqLRA==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.57.0",
"@typescript-eslint/types": "5.57.1",
"eslint-visitor-keys": "^3.3.0"
}
},
@ -13854,9 +13854,9 @@
"integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw=="
},
"axios": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz",
"integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==",
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.3.5.tgz",
"integrity": "sha512-glL/PvG/E+xCWwV8S6nCHcrfg1exGx7vxyUIivIA1iL7BIh6bePylCfVHwp6k13ao7SATxB6imau2kqY+I67kw==",
"requires": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
@ -18896,9 +18896,9 @@
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
"ts-jest": {
"version": "29.0.5",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.0.5.tgz",
"integrity": "sha512-PL3UciSgIpQ7f6XjVOmbi96vmDHUqAyqDr8YxzopDqX3kfgYtX1cuNeBjP+L9sFXi6nzsGGA6R3fP3DDDJyrxA==",
"version": "29.1.0",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.0.tgz",
"integrity": "sha512-ZhNr7Z4PcYa+JjMl62ir+zPiNJfXJN6E8hSLnaUKhOgqcn8vb3e537cpkd0FuAfRK3sR1LSqM1MOhliXNgOFPA==",
"dev": true,
"requires": {
"bs-logger": "0.x",

Просмотреть файл

@ -78,7 +78,7 @@
"app-root-path": "3.1.0",
"applicationinsights": "2.5.1",
"async-prompt": "1.0.1",
"axios": "1.3.4",
"axios": "1.3.5",
"basic-auth": "2.0.1",
"body-parser": "1.20.2",
"color-contrast-checker": "2.1.0",
@ -132,7 +132,7 @@
"@types/express-session": "1.17.7",
"@types/jest": "29.5.0",
"@types/lodash": "4.14.192",
"@types/luxon": "3.2.0",
"@types/luxon": "3.3.0",
"@types/memory-cache": "0.2.2",
"@types/morgan": "1.9.4",
"@types/node": "18.15.11",
@ -147,8 +147,8 @@
"@types/semver": "7.3.13",
"@types/simple-oauth2": "5.0.4",
"@types/validator": "13.7.14",
"@typescript-eslint/eslint-plugin": "5.57.0",
"@typescript-eslint/parser": "5.57.0",
"@typescript-eslint/eslint-plugin": "5.57.1",
"@typescript-eslint/parser": "5.57.1",
"cspell": "6.31.1",
"eslint": "8.37.0",
"eslint-config-prettier": "8.8.0",
@ -160,7 +160,7 @@
"lint-staged": "13.2.0",
"markdownlint-cli2": "0.6.0",
"prettier": "2.8.7",
"ts-jest": "29.0.5",
"ts-jest": "29.1.0",
"ts-node": "10.9.1",
"typescript": "5.0.3"
},

Просмотреть файл

@ -397,11 +397,11 @@ export class RepoWorkflowEngine {
events: webhookEvents || ['push'],
});
message = `${friendlyName} webhook added to the repository.`;
} catch (webhookCreateError) {
} catch (cause) {
error = new Error(
`The template ${templateName} defines a webhook ${friendlyName}. Adding the webhook failed. ${webhookCreateError.message()}`
`The template ${templateName} defines a webhook ${friendlyName}. Adding the webhook failed. ${cause.message()}`,
{ cause }
);
error.inner = webhookCreateError;
}
this.log.push({ error, message });
}

Просмотреть файл

@ -145,7 +145,7 @@ router.post(
);
}
} catch (error) {
if (error && error.innerError && error.innerError.status === 404) {
if (error?.cause?.status === 404) {
error = new Error(
`${username} is not a member of the ${organization.name} organization and so cannot be added to the team until they have joined the org.`
);

Просмотреть файл

@ -185,7 +185,7 @@ router.get(
return res.redirect(error.redirect);
}
// Edge case: the team no longer exists.
if (error.innerError && error.innerError.innerError && error.innerError.innerError.statusCode == 404) {
if (error?.cause?.statusCode === 404 || error.cause?.cause?.statusCode === 404) {
return closeOldRequest(false /* not a JSON client app */, pendingRequest, req, res, next);
}
return next(error);

Просмотреть файл

@ -190,8 +190,7 @@ export function popSessionVariable(req, res, variableName) {
const errorPropertiesToClone = ['stack', 'status'];
export function wrapError(error, message, userIntendedMessage?: boolean): IReposError {
const err: IReposError = new Error(message);
err.innerError = error;
const err: IReposError = new Error(message, { cause: error });
if (error) {
for (let i = 0; i < errorPropertiesToClone.length; i++) {
const key = errorPropertiesToClone[i];