Skip to content

Conversation

@DCchoudhury15
Copy link
Contributor

This PR resolves Issue #1726 by introducing a structured RepodataError type and removing the use of anyhow::Error inside write_repodata and related indexing code.

Changes include:

  • Added error.rs defining RepodataError with proper error variants.
  • Replaced all anyhow::Error usages with RepodataError.
  • Correctly mapped opendal, serde_json, and IO errors into RepodataError.
  • Updated write_repodata and sharding code to return RepodataError instead of anyhow::Error.
  • Cargo updates for adding thiserror.

This makes the error surface more predictable and fixes failing error conversions in rattler_index.

path = "src/main.rs"

[dependencies]
thiserror = "1.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use workspace dependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated — changed this error to use workspace dependency. Thanks for pointing this out.


#[derive(Debug, Error)]
pub enum RepodataError {
#[error("I/O error: {0}")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make this transparent

#[error("I/O error: {0}")]
Io(#[from] io::Error),

#[error("Serialization error: {0}")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Patch(String),

#[error("Opendal error: {0}")]
Opendal(#[from] OpendalError),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

#[error("Opendal error: {0}")]
Opendal(#[from] OpendalError),

#[error("Other error: {0}")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

)
.await?;
.await
.map_err(RepodataError::Opendal)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since from is implemented, this is not needed

Some(CACHE_CONTROL_REPODATA),
)
.await?;
.await
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Some(CACHE_CONTROL_REPODATA),
)
.await?;
.await
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baszalmstra I have updated the PR based on your feedback. Here is a summary of the changes:

Custom Error Type: Replaced anyhow::Result with a dedicated RepodataError enum in src/error.rs to allow for structured error handling.

Module Visibility: Added pub mod error; with proper documentation in src/lib.rs.

Retry Logic: Updated the index_subdir loop to properly match against RepodataError::Opendal when detecting race conditions, ensuring retries still work as intended.

Dependencies: Updated Cargo.toml to use thiserror = { workspace = true } as requested.

I've verified that cargo test, cargo clippy, and cargo doc all pass locally. Ready for another review!

let mut hasher = Sha256::new();
hasher.update(&encoded);
let digest = hasher.finalize();
Ok((k.clone(), (digest, encoded)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this clone needed?

@DCchoudhury15 DCchoudhury15 changed the title Fix error handling in write_repodata by removing anyhow::Error and adding a dedicated error type fix: Fix error handling in write_repodata by removing anyhow::Error and adding a dedicated error type Dec 11, 2025
@DCchoudhury15
Copy link
Contributor Author

i have done all the changes and also resolved my errors up for review.

@DCchoudhury15
Copy link
Contributor Author

@baszalmstra please take a look at the pr raised for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants