Skip to content

Conversation

zokhcat
Copy link

@zokhcat zokhcat commented Sep 16, 2025

No description provided.

@zokhcat zokhcat marked this pull request as ready for review September 19, 2025 19:36
@zokhcat
Copy link
Author

zokhcat commented Sep 19, 2025

@sunshowers could you please take a look at this and give a review when you have a chance?

Copy link
Member

@sunshowers sunshowers left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

store_dir: Utf8PathBuf,
default_profile: &'cfg DefaultProfileImpl,
custom_profile: Option<&'cfg CustomProfileImpl>,
inheritance_chain: Vec<&'cfg CustomProfileImpl>,
Copy link
Member

Choose a reason for hiding this comment

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

nice!

Comment on lines +1002 to +1017
// Check custom profile first, then walk up inheritance chain
if let Some(profile) = self.custom_profile {
if let Some(retries) = profile.retries {
return retries;
}
}

// Walk up inheritance chain
for parent in &self.inheritance_chain {
if let Some(retries) = parent.retries {
return retries;
}
}

// Fall back to default
self.default_profile.retries
Copy link
Member

Choose a reason for hiding this comment

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

This looks good -- you'll want to replicate this logic for all of the other config options here (can you extract this into a common function?)

));
}

visited.insert(profile_name.to_string());
Copy link
Member

Choose a reason for hiding this comment

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

Do you need the to_string here? Or can you store references to the profile name?

You might run into variance issues with storing a reference, but I think you can have another lifetime parameter for that.

}

fn check_inheritance_cycles(&self) -> Result<(), ConfigParseError> {
let mut graph = Graph::<String, (), Directed>::new();
Copy link
Member

Choose a reason for hiding this comment

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

same here, can you store references?

Err(cycle) => {
let cycle_profile = graph[cycle.node_id()].clone();
Err(ConfigParseError::new(
"Inheritance cycle detected in profile configuration",
Copy link
Member

Choose a reason for hiding this comment

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

We use lowercase for errors:

Suggested change
"Inheritance cycle detected in profile configuration",
"inheritance cycle detected in profile configuration",

Err(ConfigParseError::new(
"Inheritance cycle detected in profile configuration",
None,
ConfigParseErrorKind::InheritanceCycle(cycle_profile),
Copy link
Member

Choose a reason for hiding this comment

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

Could we use https://docs.rs/petgraph/latest/petgraph/algo/fn.kosaraju_scc.html to detect all cycles here? Each SCC returned by the algorithm is a cycle -- it would be nice to print out all such cycles here.

#[serde(default)]
archive: Option<ArchiveConfig>,
#[serde(default)]
inherit: Option<String>
Copy link
Member

@sunshowers sunshowers Sep 21, 2025

Choose a reason for hiding this comment

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

Need a trailing comma (did rustfmt not catch this?)

Ok(())
}

fn check_inheritance_cycles(&self) -> Result<(), ConfigParseError> {
Copy link
Member

Choose a reason for hiding this comment

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

We need some tests, both for inheritance and for cycles.

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