Incremental engine for long horizon agents π Star if you like it!
Rust agentic-data-frameworkaiai-agentschange-data-capturecodebase-intelligencecontext-engineeringdata-engineeringdata-indexingdata-processingetlhelp-wantedindexingknowledge-graphllmlong-horizon-agentpythonragreal-timerustsemantic-search
fix(rust-sdk): redact secrets in Debug output; Debug on connector handles (#2777)
LJ π₯₯π΄cacb346971bd
diff --git a/rust/sdk/cocoindex/src/connectors/amazon_s3.rs b/rust/sdk/cocoindex/src/connectors/amazon_s3.rsindex 48384c17..b891e228 100644--- a/rust/sdk/cocoindex/src/connectors/amazon_s3.rs+++ b/rust/sdk/cocoindex/src/connectors/amazon_s3.rs@@ -241,6 +241,15 @@ pub struct S3Client {state_id: Arc<str>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for S3Client {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("S3Client")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+impl S3Client {/// Build a client from the standard AWS environment (region, credentials, and/// `AWS_ENDPOINT_URL`). When `AWS_ENDPOINT_URL` is set (e.g. for MinIO),diff --git a/rust/sdk/cocoindex/src/connectors/azure_blob.rs b/rust/sdk/cocoindex/src/connectors/azure_blob.rsindex 248c09a3..53f01c3e 100644--- a/rust/sdk/cocoindex/src/connectors/azure_blob.rs+++ b/rust/sdk/cocoindex/src/connectors/azure_blob.rs@@ -319,7 +319,7 @@ pub enum Credential {/// of the Azure SDK's `DefaultAzureCredential` that need no interactive sign-in./// The token is for `https://storage.azure.com/`, and the identity needs/// `Storage Blob Data Reader` on the container.-#[derive(Clone, Debug)]+#[derive(Clone)]pub enum TokenCredential {/// The first of these that is configured where the process runs:/// [`ClientSecret`](Self::ClientSecret) from `AZURE_TENANT_ID`,@@ -345,6 +345,43 @@ pub enum TokenCredential {AzureCli,}+impl std::fmt::Debug for TokenCredential {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ match self {+ TokenCredential::Default => f.write_str("Default"),+ TokenCredential::ClientSecret {+ tenant_id,+ client_id,+ ..+ } => f+ .debug_struct("ClientSecret")+ .field("tenant_id", tenant_id)+ .field("client_id", client_id)+ .field("client_secret", &"<redacted>")+ .finish(),+ TokenCredential::ManagedIdentity { client_id } => f+ .debug_struct("ManagedIdentity")+ .field("client_id", client_id)+ .finish(),+ TokenCredential::AzureCli => f.write_str("AzureCli"),+ }+ }+}++/// Secrets are redacted.+impl std::fmt::Debug for Credential {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ match self {+ Credential::AccountKey(_) => f.write_str("AccountKey(<redacted>)"),+ Credential::SasToken(_) => f.write_str("SasToken(<redacted>)"),+ Credential::BearerToken(_) => f.write_str("BearerToken(<redacted>)"),+ Credential::TokenCredential(source) => {+ f.debug_tuple("TokenCredential").field(source).finish()+ }+ }+ }+}+enum Auth {SharedKey { key: Vec<u8> },Sas { query: String },@@ -369,6 +406,16 @@ pub struct ContainerClient {inner: Arc<ContainerClientInner>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for ContainerClient {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("ContainerClient")+ .field("account_name", &self.inner.account_name)+ .field("container_name", &self.inner.container_name)+ .finish_non_exhaustive()+ }+}+impl ContainerClient {/// Build a client for the container `container_name` of the storage account/// at `account_url` (`https://myaccount.blob.core.windows.net`).diff --git a/rust/sdk/cocoindex/src/connectors/bigquery.rs b/rust/sdk/cocoindex/src/connectors/bigquery.rsindex e12e6238..105a5173 100644--- a/rust/sdk/cocoindex/src/connectors/bigquery.rs+++ b/rust/sdk/cocoindex/src/connectors/bigquery.rs@@ -131,6 +131,15 @@ pub struct BigQueryConnection {inner: Arc<ConnectionInner>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for BigQueryConnection {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("BigQueryConnection")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+impl BigQueryConnection {/// Resolve credentials (see the module docs) and build a connection. No/// request is made until the first query.diff --git a/rust/sdk/cocoindex/src/connectors/doris.rs b/rust/sdk/cocoindex/src/connectors/doris.rsindex 25e8c39d..e0074ea2 100644--- a/rust/sdk/cocoindex/src/connectors/doris.rs+++ b/rust/sdk/cocoindex/src/connectors/doris.rs@@ -52,8 +52,8 @@ use crate::target_state::{/// Connection configuration for a Doris cluster. Mirrors Python's/// `DorisConnectionConfig`. Construct with [`DorisConfig::new`] and adjust with-/// the builder setters.-#[derive(Clone, Debug)]+/// the builder setters. Its `Debug` output redacts the password.+#[derive(Clone)]pub struct DorisConfig {/// Frontend host (used for both the MySQL query port and Stream Load HTTP).pub fe_host: String,@@ -179,6 +179,37 @@ pub struct DorisConnection {state_id: Arc<str>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for DorisConnection {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("DorisConnection")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}++impl std::fmt::Debug for DorisConfig {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("DorisConfig")+ .field("fe_host", &self.fe_host)+ .field("database", &self.database)+ .field("fe_http_port", &self.fe_http_port)+ .field("query_port", &self.query_port)+ .field("username", &self.username)+ .field("password", &"<redacted>")+ .field("enable_https", &self.enable_https)+ .field("be_load_host", &self.be_load_host)+ .field("batch_size", &self.batch_size)+ .field("stream_load_timeout", &self.stream_load_timeout)+ .field("max_retries", &self.max_retries)+ .field("retry_base_delay", &self.retry_base_delay)+ .field("retry_max_delay", &self.retry_max_delay)+ .field("replication_num", &self.replication_num)+ .field("buckets", &self.buckets)+ .finish()+ }+}+impl DorisConnection {/// Connect to a Doris cluster. Opens a MySQL connection pool to the FE query/// port (used for DDL/DELETE) and builds an HTTP client for Stream Load. The@@ -1895,6 +1926,13 @@ mod tests {}}+ #[test]+ fn config_debug_redacts_the_password() {+ let debug = format!("{:?}", config().password("hunter2"));+ assert!(!debug.contains("hunter2"), "{debug}");+ assert!(debug.contains("<redacted>"), "{debug}");+ }+fn config() -> DorisConfig {DorisConfig::new("localhost", "testdb")}diff --git a/rust/sdk/cocoindex/src/connectors/falkordb.rs b/rust/sdk/cocoindex/src/connectors/falkordb.rsindex 0a87c3d4..57096f10 100644--- a/rust/sdk/cocoindex/src/connectors/falkordb.rs+++ b/rust/sdk/cocoindex/src/connectors/falkordb.rs@@ -19,6 +19,15 @@ pub struct Graph {graph: Arc<str>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for Graph {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("Graph")+ .field("graph", &&*self.graph)+ .finish_non_exhaustive()+ }+}+fn normalize_uri(uri: &str) -> String {uri.strip_prefix("falkor://").map(|rest| format!("redis://{rest}"))diff --git a/rust/sdk/cocoindex/src/connectors/gdrive.rs b/rust/sdk/cocoindex/src/connectors/gdrive.rsindex 0cc009c1..2ecd3802 100644--- a/rust/sdk/cocoindex/src/connectors/gdrive.rs+++ b/rust/sdk/cocoindex/src/connectors/gdrive.rs@@ -534,6 +534,15 @@ pub struct GoogleDriveClient {inner: Arc<ClientInner>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for GoogleDriveClient {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("GoogleDriveClient")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+impl GoogleDriveClient {/// Build a client from a service-account JSON key file (the standard/// `type: service_account` key downloaded from Google Cloud).diff --git a/rust/sdk/cocoindex/src/connectors/iggy.rs b/rust/sdk/cocoindex/src/connectors/iggy.rsindex 7ae19a5d..ec921b67 100644--- a/rust/sdk/cocoindex/src/connectors/iggy.rs+++ b/rust/sdk/cocoindex/src/connectors/iggy.rs@@ -77,6 +77,15 @@ pub struct IggyProducer {state_id: Arc<str>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for IggyProducer {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("IggyProducer")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+impl IggyProducer {/// Connect to an Iggy server from a connection string, e.g./// `iggy://iggy:iggy@localhost:8090`. Credentials embedded in the string are@@ -635,6 +644,15 @@ pub struct IggyConsumer {state_id: Arc<str>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for IggyConsumer {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("IggyConsumer")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+impl IggyConsumer {/// Connect to an Iggy server from a connection string, e.g./// `iggy://iggy:iggy@localhost:8090`.diff --git a/rust/sdk/cocoindex/src/connectors/kafka.rs b/rust/sdk/cocoindex/src/connectors/kafka.rsindex cbcf6e25..02031dd4 100644--- a/rust/sdk/cocoindex/src/connectors/kafka.rs+++ b/rust/sdk/cocoindex/src/connectors/kafka.rs@@ -240,6 +240,15 @@ pub struct KafkaProducer {state_id: Arc<str>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for KafkaProducer {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("KafkaProducer")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+impl KafkaProducer {/// Connect to a Kafka (or Redpanda) cluster given its bootstrap servers,/// e.g. `["localhost:9092"]`, in plaintext without authentication.@@ -981,6 +990,15 @@ pub struct KafkaConsumer {consumer_group: Option<Arc<str>>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for KafkaConsumer {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("KafkaConsumer")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+impl KafkaConsumer {/// Connect to a Kafka (or Redpanda) cluster given its bootstrap servers, in/// plaintext without authentication and without a consumer group.diff --git a/rust/sdk/cocoindex/src/connectors/lancedb.rs b/rust/sdk/cocoindex/src/connectors/lancedb.rsindex 4ba26e99..86b3fac5 100644--- a/rust/sdk/cocoindex/src/connectors/lancedb.rs+++ b/rust/sdk/cocoindex/src/connectors/lancedb.rs@@ -55,6 +55,15 @@ pub struct LanceDatabase {state_id: Arc<str>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for LanceDatabase {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("LanceDatabase")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+/// Options for [`LanceDatabase::connect_with_options`], the connection options/// Python passes through `connect_async(uri, **options)` for a local or/// object-store database. (LanceDB Cloud, `db://`, is not built into the SDK'sdiff --git a/rust/sdk/cocoindex/src/connectors/oci_object_storage.rs b/rust/sdk/cocoindex/src/connectors/oci_object_storage.rsindex 16c02e52..ee70ee1c 100644--- a/rust/sdk/cocoindex/src/connectors/oci_object_storage.rs+++ b/rust/sdk/cocoindex/src/connectors/oci_object_storage.rs@@ -70,7 +70,8 @@ const LIST_FIELDS: &str = "name,size,md5,timeModified,etag";/// Credentials and endpoint for an OCI API-key principal, as found in an/// `~/.oci/config` profile (the same file the OCI CLI and Python SDK read).-#[derive(Clone, Debug)]+/// Its `Debug` output redacts the pass-phrase.+#[derive(Clone)]pub struct OciConfig {/// Tenancy OCID.pub tenancy: String,@@ -87,6 +88,22 @@ pub struct OciConfig {pub pass_phrase: Option<String>,}+impl std::fmt::Debug for OciConfig {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("OciConfig")+ .field("tenancy", &self.tenancy)+ .field("user", &self.user)+ .field("fingerprint", &self.fingerprint)+ .field("key_file", &self.key_file)+ .field("region", &self.region)+ .field(+ "pass_phrase",+ &self.pass_phrase.as_ref().map(|_| "<redacted>"),+ )+ .finish()+ }+}+impl OciConfig {/// Load a profile from an OCI config file (INI format). `profile` selects the/// `[PROFILE]` section (e.g. `DEFAULT`).@@ -667,6 +684,15 @@ pub struct OciClient {inner: Arc<OciClientInner>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for OciClient {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("OciClient")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+impl OciClient {/// Build a client from an `~/.oci/config` profile. Honors `OCI_CONFIG_FILE`/// (default `~/.oci/config`) and `OCI_PROFILE` / `OCI_CLI_PROFILE` (defaultdiff --git a/rust/sdk/cocoindex/src/connectors/qdrant.rs b/rust/sdk/cocoindex/src/connectors/qdrant.rsindex 4c51fd7c..633e163c 100644--- a/rust/sdk/cocoindex/src/connectors/qdrant.rs+++ b/rust/sdk/cocoindex/src/connectors/qdrant.rs@@ -51,6 +51,15 @@ pub struct QdrantConnection {state_id: Arc<str>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for QdrantConnection {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("QdrantConnection")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+impl QdrantConnection {/// Connect to a Qdrant server (gRPC URL, e.g. `http://localhost:6334`)/// with the client's default settings. For an API key, TLS or timeouts,diff --git a/rust/sdk/cocoindex/src/connectors/snowflake.rs b/rust/sdk/cocoindex/src/connectors/snowflake.rsindex 6f65aaf6..db234f7d 100644--- a/rust/sdk/cocoindex/src/connectors/snowflake.rs+++ b/rust/sdk/cocoindex/src/connectors/snowflake.rs@@ -132,6 +132,15 @@ pub struct SnowflakeConnection {inner: Arc<ConnectionInner>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for SnowflakeConnection {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("SnowflakeConnection")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+impl SnowflakeConnection {/// Build a connection. No request is made until the first statement.pub fn new(config: SnowflakeConfig) -> Self {diff --git a/rust/sdk/cocoindex/src/connectors/sqlite.rs b/rust/sdk/cocoindex/src/connectors/sqlite.rsindex 6d07b251..d46f2540 100644--- a/rust/sdk/cocoindex/src/connectors/sqlite.rs+++ b/rust/sdk/cocoindex/src/connectors/sqlite.rs@@ -81,6 +81,15 @@ pub struct Database {state_id: Arc<str>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for Database {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("Database")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+impl Database {/// Open (creating if missing) a SQLite database at `path` with the default/// [`ConnectOptions`].diff --git a/rust/sdk/cocoindex/src/connectors/surrealdb.rs b/rust/sdk/cocoindex/src/connectors/surrealdb.rsindex 9513c494..73cde87f 100644--- a/rust/sdk/cocoindex/src/connectors/surrealdb.rs+++ b/rust/sdk/cocoindex/src/connectors/surrealdb.rs@@ -267,14 +267,24 @@ pub struct Graph {state_id: Arc<str>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for Graph {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("Graph")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+fn surreal_err(e: surrealdb::Error) -> Error {Error::engine(format!("surrealdb: {e}"))}/// How [`Graph::connect_with_credentials`] signs in (Python's `credentials`/// dict of `ConnectionFactory`). A namespace or database user belongs to the-/// namespace and database the connection uses.-#[derive(Clone, Debug)]+/// namespace and database the connection uses. Its `Debug` output redacts+/// passwords and record-access parameters.+#[derive(Clone)]pub enum Credentials {/// Sign in as a root user.Root { username: String, password: String },@@ -289,6 +299,28 @@ pub enum Credentials {None,}+impl std::fmt::Debug for Credentials {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ let user = |f: &mut std::fmt::Formatter<'_>, kind: &str, username: &str| {+ f.debug_struct(kind)+ .field("username", &username)+ .field("password", &"<redacted>")+ .finish()+ };+ match self {+ Credentials::Root { username, .. } => user(f, "Root", username),+ Credentials::Namespace { username, .. } => user(f, "Namespace", username),+ Credentials::Database { username, .. } => user(f, "Database", username),+ Credentials::Record { access, .. } => f+ .debug_struct("Record")+ .field("access", access)+ .field("params", &"<redacted>")+ .finish(),+ Credentials::None => f.write_str("None"),+ }+ }+}+impl Graph {/// Connect over WebSocket and sign in as the root user `user`.pub async fn connect(diff --git a/rust/sdk/cocoindex/src/connectors/turbopuffer.rs b/rust/sdk/cocoindex/src/connectors/turbopuffer.rsindex 9d92deef..0b001efb 100644--- a/rust/sdk/cocoindex/src/connectors/turbopuffer.rs+++ b/rust/sdk/cocoindex/src/connectors/turbopuffer.rs@@ -43,6 +43,15 @@ pub struct TurbopufferConnection {inner: Arc<ConnInner>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for TurbopufferConnection {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("TurbopufferConnection")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+impl TurbopufferConnection {/// Connect to a Turbopuffer region (e.g. `gcp-us-central1`) with an API key.pub fn new(region: &str, api_key: &str) -> Self {diff --git a/rust/sdk/cocoindex/src/connectors/valkey.rs b/rust/sdk/cocoindex/src/connectors/valkey.rsindex 30929402..4b9b1a7b 100644--- a/rust/sdk/cocoindex/src/connectors/valkey.rs+++ b/rust/sdk/cocoindex/src/connectors/valkey.rs@@ -44,6 +44,15 @@ pub struct Valkey {state_id: Arc<str>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for Valkey {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("Valkey")+ .field("state_id", &self.state_id())+ .finish_non_exhaustive()+ }+}+/// Connection settings for [`Valkey::connect_with_config`] β the Rust analogue/// of Python's `create_client_config`. For anything these fields do not cover/// (client certificates, a username, a database number), build adiff --git a/rust/sdk/cocoindex/src/connectors/zvec.rs b/rust/sdk/cocoindex/src/connectors/zvec.rsindex 743220dc..a41e3016 100644--- a/rust/sdk/cocoindex/src/connectors/zvec.rs+++ b/rust/sdk/cocoindex/src/connectors/zvec.rs@@ -122,6 +122,15 @@ pub struct ManagedConnection {inner: Arc<ConnectionInner>,}+/// Shows the handle's identity only, never credentials.+impl std::fmt::Debug for ManagedConnection {+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {+ f.debug_struct("ManagedConnection")+ .field("base_path", &self.inner.base_path)+ .finish_non_exhaustive()+ }+}+/// Create a [`ManagedConnection`] rooted at `base_path`. The directory is/// created if missing.pub fn connect(base_path: impl AsRef<Path>, options: ConnectOptions) -> Result<ManagedConnection> {diff --git a/rust/sdk/cocoindex/tests/sqlite_target.rs b/rust/sdk/cocoindex/tests/sqlite_target.rsindex 4c5de3cd..8396c844 100644--- a/rust/sdk/cocoindex/tests/sqlite_target.rs+++ b/rust/sdk/cocoindex/tests/sqlite_target.rs@@ -651,8 +651,7 @@ async fn sqlite_connect_with_vec_fails_when_the_extension_is_missing() {let result =sqlite::Database::connect_with_vec(path.to_str().unwrap(), missing.to_str().unwrap()).await;let message = result- .err()- .expect("a missing sqlite-vec library must fail the connection")+ .expect_err("a missing sqlite-vec library must fail the connection").to_string();assert!(message.contains("sqlite"), "{message}");}