Skip to content

Commit d454f9c

Browse files
Make GitHub fast path errors non-fatal (#10859)
## Summary For example: in the linked issue, the user has a symlink at `pyproject.toml`. The GitHub CDN doesn't give us any way to determine whether a file is a symlink, so we should just log the error and move on to the slow path. Closes #10857
1 parent 62f8a48 commit d454f9c

File tree

1 file changed

+37
-21
lines changed
  • crates/uv-distribution/src/source

1 file changed

+37
-21
lines changed

crates/uv-distribution/src/source/mod.rs

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,39 +1499,55 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
14991499
}
15001500

15011501
// If this is GitHub URL, attempt to resolve to a precise commit using the GitHub API.
1502-
if let Some(precise) = self
1502+
match self
15031503
.build_context
15041504
.git()
15051505
.github_fast_path(
15061506
resource.git,
15071507
client.unmanaged.uncached_client(resource.url).clone(),
15081508
)
1509-
.await?
1509+
.await
15101510
{
1511-
// There's no need to check the cache, since we can't use cached metadata if there are
1512-
// sources, and we can't know if there are sources without fetching the
1513-
// `pyproject.toml`.
1514-
//
1515-
// For the same reason, there's no need to write to the cache, since we won't be able to
1516-
// use it on subsequent runs.
1517-
if let Some(metadata) = self
1518-
.github_metadata(precise, source, resource, client)
1519-
.await?
1520-
{
1521-
// Validate the metadata, but ignore it if the metadata doesn't match.
1522-
match validate_metadata(source, &metadata) {
1523-
Ok(()) => {
1524-
debug!("Found static metadata via GitHub fast path for: {source}");
1525-
return Ok(ArchiveMetadata {
1526-
metadata: Metadata::from_metadata23(metadata),
1527-
hashes: vec![],
1528-
});
1511+
Ok(Some(precise)) => {
1512+
// There's no need to check the cache, since we can't use cached metadata if there are
1513+
// sources, and we can't know if there are sources without fetching the
1514+
// `pyproject.toml`.
1515+
//
1516+
// For the same reason, there's no need to write to the cache, since we won't be able to
1517+
// use it on subsequent runs.
1518+
match self
1519+
.github_metadata(precise, source, resource, client)
1520+
.await
1521+
{
1522+
Ok(Some(metadata)) => {
1523+
// Validate the metadata, but ignore it if the metadata doesn't match.
1524+
match validate_metadata(source, &metadata) {
1525+
Ok(()) => {
1526+
debug!("Found static metadata via GitHub fast path for: {source}");
1527+
return Ok(ArchiveMetadata {
1528+
metadata: Metadata::from_metadata23(metadata),
1529+
hashes: vec![],
1530+
});
1531+
}
1532+
Err(err) => {
1533+
debug!("Ignoring `pyproject.toml` from GitHub for {source}: {err}");
1534+
}
1535+
}
1536+
}
1537+
Ok(None) => {
1538+
// Nothing to do.
15291539
}
15301540
Err(err) => {
1531-
debug!("Ignoring `pyproject.toml` from GitHub for {source}: {err}");
1541+
debug!("Failed to fetch `pyproject.toml` via GitHub fast path for: {source} ({err})");
15321542
}
15331543
}
15341544
}
1545+
Ok(None) => {
1546+
// Nothing to do.
1547+
}
1548+
Err(err) => {
1549+
debug!("Failed to resolve commit via GitHub fast path for: {source} ({err})");
1550+
}
15351551
}
15361552

15371553
// Fetch the Git repository.

0 commit comments

Comments
 (0)