mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
fix(http): improve error logging (#18454)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
parent
67043c4381
commit
cdec83463c
9 changed files with 18 additions and 55 deletions
|
@ -36,10 +36,7 @@ export async function fetchJSONFile(
|
||||||
if (err instanceof ExternalHostError) {
|
if (err instanceof ExternalHostError) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
logger.debug(
|
logger.debug(`Preset file ${fileName} not found in ${repo}`);
|
||||||
{ statusCode: err.statusCode, url: `${endpoint}${url}` },
|
|
||||||
`Failed to retrieve ${fileName} from repo`
|
|
||||||
);
|
|
||||||
throw new Error(PRESET_DEP_NOT_FOUND);
|
throw new Error(PRESET_DEP_NOT_FOUND);
|
||||||
}
|
}
|
||||||
if (!res.body.isLastPage) {
|
if (!res.body.isLastPage) {
|
||||||
|
|
|
@ -24,10 +24,7 @@ export async function fetchJSONFile(
|
||||||
if (err instanceof ExternalHostError) {
|
if (err instanceof ExternalHostError) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
logger.debug(
|
logger.debug(`Preset file ${fileName} not found in ${repo}`);
|
||||||
{ statusCode: err.statusCode, repo, fileName },
|
|
||||||
`Failed to retrieve ${fileName} from repo`
|
|
||||||
);
|
|
||||||
throw new Error(PRESET_DEP_NOT_FOUND);
|
throw new Error(PRESET_DEP_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,7 @@ export async function fetchJSONFile(
|
||||||
if (err instanceof ExternalHostError) {
|
if (err instanceof ExternalHostError) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
logger.debug(
|
logger.debug(`Preset file ${fileName} not found in ${repo}`);
|
||||||
{ statusCode: err.statusCode, url },
|
|
||||||
`Failed to retrieve ${fileName} from repo`
|
|
||||||
);
|
|
||||||
throw new Error(PRESET_DEP_NOT_FOUND);
|
throw new Error(PRESET_DEP_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,10 +57,7 @@ export async function fetchJSONFile(
|
||||||
if (err instanceof ExternalHostError) {
|
if (err instanceof ExternalHostError) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
logger.debug(
|
logger.debug(`Preset file ${fileName} not found in ${repo}`);
|
||||||
{ statusCode: err.statusCode, url },
|
|
||||||
`Failed to retrieve ${fileName} from repo`
|
|
||||||
);
|
|
||||||
throw new Error(PRESET_DEP_NOT_FOUND);
|
throw new Error(PRESET_DEP_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,7 @@ export async function fetchJSONFile(
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(`Preset file ${fileName} not found in ${repo}`);
|
||||||
{ err, repo, fileName },
|
|
||||||
`Failed to retrieve ${fileName} from repo ${repo}`
|
|
||||||
);
|
|
||||||
|
|
||||||
throw new Error(PRESET_DEP_NOT_FOUND);
|
throw new Error(PRESET_DEP_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,35 +157,12 @@ export async function getDependency(
|
||||||
}
|
}
|
||||||
return dep;
|
return dep;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.statusCode === 401 || err.statusCode === 403) {
|
const ignoredStatusCodes = [401, 402, 403, 404];
|
||||||
logger.debug(
|
const ignoredResponseCodes = ['ENOTFOUND'];
|
||||||
{
|
if (
|
||||||
packageUrl,
|
ignoredStatusCodes.includes(err.statusCode) ||
|
||||||
err,
|
ignoredResponseCodes.includes(err.code)
|
||||||
statusCode: err.statusCode,
|
) {
|
||||||
packageName,
|
|
||||||
},
|
|
||||||
`Dependency lookup failure: unauthorized`
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (err.statusCode === 402) {
|
|
||||||
logger.debug(
|
|
||||||
{
|
|
||||||
packageUrl,
|
|
||||||
err,
|
|
||||||
statusCode: err.statusCode,
|
|
||||||
packageName,
|
|
||||||
},
|
|
||||||
`Dependency lookup failure: payment required`
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (err.statusCode === 404 || err.code === 'ENOTFOUND') {
|
|
||||||
logger.debug(
|
|
||||||
{ err, packageName },
|
|
||||||
`Dependency lookup failure: not found`
|
|
||||||
);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (uri.host === 'registry.npmjs.org') {
|
if (uri.host === 'registry.npmjs.org') {
|
||||||
|
|
|
@ -154,11 +154,6 @@ function handleGotError(
|
||||||
) {
|
) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (err.statusCode === 404) {
|
|
||||||
logger.debug({ url: path }, 'GitHub 404');
|
|
||||||
} else {
|
|
||||||
logger.debug({ err }, 'Unknown GitHub error');
|
|
||||||
}
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,12 @@ async function gotTask<T>(
|
||||||
duration =
|
duration =
|
||||||
error.timings?.phases.total ??
|
error.timings?.phases.total ??
|
||||||
/* istanbul ignore next: can't be tested */ 0;
|
/* istanbul ignore next: can't be tested */ 0;
|
||||||
|
const method = options.method?.toUpperCase() ?? 'GET';
|
||||||
|
const code = error.code ?? 'UNKNOWN';
|
||||||
|
const retryCount = error.response?.retryCount ?? -1;
|
||||||
|
logger.debug(
|
||||||
|
`${method} ${url} = (code=${code}, statusCode=${statusCode} retryCount=${retryCount}, duration=${duration})`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
@ -82,7 +82,7 @@ export async function lookupUpdates(
|
||||||
// If dependency lookup fails then warn and return
|
// If dependency lookup fails then warn and return
|
||||||
const warning: ValidationMessage = {
|
const warning: ValidationMessage = {
|
||||||
topic: depName,
|
topic: depName,
|
||||||
message: `Failed to look up dependency ${depName}`,
|
message: `Failed to look up ${datasource} dependency ${depName}`,
|
||||||
};
|
};
|
||||||
logger.debug({ dependency: depName, packageFile }, warning.message);
|
logger.debug({ dependency: depName, packageFile }, warning.message);
|
||||||
// TODO: return warnings in own field
|
// TODO: return warnings in own field
|
||||||
|
|
Loading…
Reference in a new issue