Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

import { Logger } from '@kbn/core/server';
import { PackageClient } from '@kbn/fleet-plugin/server';
import { PackageNotFoundError } from '@kbn/fleet-plugin/server/errors';
import {
FleetUnauthorizedError,
PackageNotFoundError,
RegistryResponseError,
} from '@kbn/fleet-plugin/server/errors';
import { PackageInfo, RegistryDataStream } from '@kbn/fleet-plugin/common';
import { IntegrationType } from '../../../common/api_types';

Expand Down Expand Up @@ -89,9 +93,21 @@ const fetchDatasets = async (options: {
}

const { name, version, logger } = options;
logger.error(
`There was an error when trying to fetch information about package ${name} version ${version}: ${error}`
);
const message = `There was an error when trying to fetch information about package ${name} version ${version}: ${error}`;

// Registry 4xx / Fleet permission denials are user-facing, not Kibana faults.
// A registry error without a status stays at error so transient failures stay visible.
const shouldLogAsDebug =
(error instanceof RegistryResponseError &&
error.status !== undefined &&
error.status < 500) ||
error instanceof FleetUnauthorizedError;

if (shouldLogAsDebug) {
logger.debug(message);
} else {
logger.error(message);
}

return {};
}
Expand Down