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) {
|
||||
throw err;
|
||||
}
|
||||
logger.debug(
|
||||
{ statusCode: err.statusCode, url: `${endpoint}${url}` },
|
||||
`Failed to retrieve ${fileName} from repo`
|
||||
);
|
||||
logger.debug(`Preset file ${fileName} not found in ${repo}`);
|
||||
throw new Error(PRESET_DEP_NOT_FOUND);
|
||||
}
|
||||
if (!res.body.isLastPage) {
|
||||
|
|
|
@ -24,10 +24,7 @@ export async function fetchJSONFile(
|
|||
if (err instanceof ExternalHostError) {
|
||||
throw err;
|
||||
}
|
||||
logger.debug(
|
||||
{ statusCode: err.statusCode, repo, fileName },
|
||||
`Failed to retrieve ${fileName} from repo`
|
||||
);
|
||||
logger.debug(`Preset file ${fileName} not found in ${repo}`);
|
||||
throw new Error(PRESET_DEP_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,7 @@ export async function fetchJSONFile(
|
|||
if (err instanceof ExternalHostError) {
|
||||
throw err;
|
||||
}
|
||||
logger.debug(
|
||||
{ statusCode: err.statusCode, url },
|
||||
`Failed to retrieve ${fileName} from repo`
|
||||
);
|
||||
logger.debug(`Preset file ${fileName} not found in ${repo}`);
|
||||
throw new Error(PRESET_DEP_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,10 +57,7 @@ export async function fetchJSONFile(
|
|||
if (err instanceof ExternalHostError) {
|
||||
throw err;
|
||||
}
|
||||
logger.debug(
|
||||
{ statusCode: err.statusCode, url },
|
||||
`Failed to retrieve ${fileName} from repo`
|
||||
);
|
||||
logger.debug(`Preset file ${fileName} not found in ${repo}`);
|
||||
throw new Error(PRESET_DEP_NOT_FOUND);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,7 @@ export async function fetchJSONFile(
|
|||
throw err;
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
{ err, repo, fileName },
|
||||
`Failed to retrieve ${fileName} from repo ${repo}`
|
||||
);
|
||||
logger.debug(`Preset file ${fileName} not found in ${repo}`);
|
||||
|
||||
throw new Error(PRESET_DEP_NOT_FOUND);
|
||||
}
|
||||
|
|
|
@ -157,35 +157,12 @@ export async function getDependency(
|
|||
}
|
||||
return dep;
|
||||
} catch (err) {
|
||||
if (err.statusCode === 401 || err.statusCode === 403) {
|
||||
logger.debug(
|
||||
{
|
||||
packageUrl,
|
||||
err,
|
||||
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`
|
||||
);
|
||||
const ignoredStatusCodes = [401, 402, 403, 404];
|
||||
const ignoredResponseCodes = ['ENOTFOUND'];
|
||||
if (
|
||||
ignoredStatusCodes.includes(err.statusCode) ||
|
||||
ignoredResponseCodes.includes(err.code)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
if (uri.host === 'registry.npmjs.org') {
|
||||
|
|
|
@ -154,11 +154,6 @@ function handleGotError(
|
|||
) {
|
||||
return err;
|
||||
}
|
||||
if (err.statusCode === 404) {
|
||||
logger.debug({ url: path }, 'GitHub 404');
|
||||
} else {
|
||||
logger.debug({ err }, 'Unknown GitHub error');
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,12 @@ async function gotTask<T>(
|
|||
duration =
|
||||
error.timings?.phases.total ??
|
||||
/* 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;
|
||||
|
|
|
@ -82,7 +82,7 @@ export async function lookupUpdates(
|
|||
// If dependency lookup fails then warn and return
|
||||
const warning: ValidationMessage = {
|
||||
topic: depName,
|
||||
message: `Failed to look up dependency ${depName}`,
|
||||
message: `Failed to look up ${datasource} dependency ${depName}`,
|
||||
};
|
||||
logger.debug({ dependency: depName, packageFile }, warning.message);
|
||||
// TODO: return warnings in own field
|
||||
|
|
Loading…
Reference in a new issue