Skip to content

Add TOML configuration to the autopilot#4147

Open
jmg-duarte wants to merge 12 commits intomainfrom
jmgd/config-drivers
Open

Add TOML configuration to the autopilot#4147
jmg-duarte wants to merge 12 commits intomainfrom
jmgd/config-drivers

Conversation

@jmg-duarte
Copy link
Contributor

Description

Kicks off #4005; to start only one of the more annoying arguments was migrated to validate the approach.

Changes

  • Add an optional config path
  • Remove the drivers CLI arg
  • Move the drivers argument to the TOML parsing

How to test

  • Migrate the drivers argument to TOML in the infra repo
  • Run in staging

@jmg-duarte jmg-duarte marked this pull request as ready for review February 13, 2026 10:21
@jmg-duarte jmg-duarte requested a review from a team as a code owner February 13, 2026 10:21
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces TOML-based configuration for the autopilot service, migrating the drivers argument from a CLI flag. While this is a positive step for configuration management, a critical security vulnerability has been identified: sensitive external service URLs (including node URLs and solver URLs) are logged in plain text, potentially exposing API keys or authentication tokens. It is crucial to implement masking utilities for all URLs that may contain secrets before logging. Furthermore, the PR has critical functional issues: a necessary validation check for drivers configuration was removed without replacement, risking an invalid service state, and the fairness_threshold configuration for solvers appears to be removed without documentation, which could lead to a significant functional regression, with misleading tests.

Comment on lines 323 to 326
Configuration {
// replace the --drivers argument with a vec of Solver structs
drivers: vec![Solver::new(
"test_solver".to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's have a helper function writing the config to a file so we can separate the logic of writing the file from building the exact configuration that's needed for a given test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I follow here. You mean setting up the temp dir and so on?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. Serializing the config struct and writing it to a temp file was duplicated in 2 places when a helper function is very simple for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've done that in the mean time , the to_temp_path function

Comment on lines 385 to 387
// Create TOML config file for the driver
let config_dir = std::env::temp_dir().join("cow-e2e-autopilot");
std::fs::create_dir_all(&config_dir).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for sometimes serializing a config rust struct and sometimes handwriting the toml string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was all automated with Claude, I've also added a better API since so I'll clear this up

Copy link
Contributor

Choose a reason for hiding this comment

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

This was all automated with Claude

In order to avoid wasting time on reviewing unfinished stuff please first make sure to review your PR yourself. Also while you are actively working on a PR mark it as a draft so we know that we can ignore notifications.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did, I think this was the sole one that didn't match the pattern

Fix to_temp_path() to actually serialize and write the TOML config
content instead of creating an empty file.

Replace manual temp dir/file creation in 6 e2e test files (12
occurrences) with the cleaner to_temp_path() helper, which uses
tempfile::NamedTempFile for automatic cleanup on drop.
Comment on lines +34 to +61
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub enum Account {
/// AWS KMS is used to retrieve the solver public key
#[serde(deserialize_with = "deserialize_arn")]
Kms(Arn),
/// Solver public key
Address(Address),
}

// Wrapper type for AWS ARN identifiers
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
pub struct Arn(pub String);

fn deserialize_arn<'de, D>(deserializer: D) -> Result<Arn, D::Error>
where
D: Deserializer<'de>,
{
let raw_arn = String::deserialize(deserializer)?;
if raw_arn.starts_with("arn:aws:kms:") {
Ok(Arn(raw_arn))
} else {
Err(serde::de::Error::invalid_value(
serde::de::Unexpected::Str(raw_arn.as_str()),
&"expected value starting with \"arn:aws:kms\"",
))
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it duplicate the logic implemented in the driver crate? Maybe it makes sense to extract it somewhere, so it is accessible by both crates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Slightly, but the driver does things a little differently. I'd like to keep this PR focused and simple enough for review

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.

3 participants