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

Add warning field to fetch logs response. #262

Merged
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
10 changes: 10 additions & 0 deletions crates/api/src/v1/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ pub struct FetchLogsResponse {
/// The package records appended since last known package record ids.
#[serde(default, skip_serializing_if = "IndexMap::is_empty")]
pub packages: IndexMap<LogId, Vec<PublishedRecord>>,
/// An optional list of warnings.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub warnings: Vec<FetchWarning>,
}

/// Represents a fetch package names request.
Expand All @@ -72,6 +75,13 @@ pub struct FetchPackageNamesResponse {
pub packages: IndexMap<LogId, Option<PackageName>>,
}

/// A warning message.
#[derive(Serialize, Deserialize, Debug)]
pub struct FetchWarning {
/// The warning message itself
pub message: String,
}

/// Represents a fetch API error.
#[non_exhaustive]
#[derive(Debug, Error)]
Expand Down
5 changes: 5 additions & 0 deletions crates/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,11 @@ impl<R: RegistryStorage, C: ContentStorage, N: NamespaceMapStorage> Client<R, C,
packages: Cow::Borrowed(&last_known),
})
.await
.inspect(|res| {
for warning in res.warnings.iter() {
tracing::warn!("Fetch warning from registry: {}", warning.message);
}
})
.map_err(|e| {
ClientError::translate_log_not_found(e, |id| {
packages.get(id).map(|p| p.name.clone())
Expand Down
12 changes: 12 additions & 0 deletions crates/server/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,12 @@ components:
maxItems: 1000
items:
$ref: "#/components/schemas/PublishedRecordEnvelope"
warnings:
type: array
description: An optional list of warnings.
maxItems: 1000
items:
$ref: "#/components/schemas/FetchWarning"
packages:
type: object
description: The map of package log identifier to package records.
Expand Down Expand Up @@ -1085,6 +1091,12 @@ components:
maxLength: 1048576
example: "ZXhhbXBsZQ=="
- $ref: "#/components/schemas/Signature"
FetchWarning:
description: A warning message
properties:
message:
description: The warning message itself.
type: string
PublishedRecordEnvelope:
description: A signed envelope body with the published registry log index.
allOf:
Expand Down
1 change: 1 addition & 0 deletions crates/server/src/api/v1/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ async fn fetch_logs(
more,
operator,
packages: map,
warnings: Vec::default(),
}))
}

Expand Down
Loading