Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(composio): stop persisting the pinned key in serialized config

oxoxDev08e82fff3117
diff --git a/crates/openhuman-core/src/config/schema/tools/integrations.rs b/crates/openhuman-core/src/config/schema/tools/integrations.rs
index a3bf707c22..047b1eb0fd 100644
--- a/crates/openhuman-core/src/config/schema/tools/integrations.rs
+++ b/crates/openhuman-core/src/config/schema/tools/integrations.rs
@@ -86,7 +86,6 @@ impl ComposioConfig {
/// its key and entity, and no fallback to the shared credential store.
pub fn pin_host_credential(&mut self, credential: ComposioHostCredential) {
self.mode = COMPOSIO_MODE_DIRECT.into();
- self.api_key = Some(credential.api_key.clone());
self.entity_id = credential.entity_id.clone();
self.host_credential = Some(credential);
}
@@ -322,3 +321,7 @@ pub struct IntegrationsConfig {
#[cfg(test)]
#[path = "integrations_integration_toggle_tests_tests.rs"]
mod integration_toggle_tests;
+
+#[cfg(test)]
+#[path = "integrations_host_credential_tests.rs"]
+mod host_credential_tests;
diff --git a/crates/openhuman-core/src/config/schema/tools/integrations_host_credential_tests.rs b/crates/openhuman-core/src/config/schema/tools/integrations_host_credential_tests.rs
new file mode 100644
index 0000000000..7f6f6f5928
--- /dev/null
+++ b/crates/openhuman-core/src/config/schema/tools/integrations_host_credential_tests.rs
@@ -0,0 +1,43 @@
+use super::*;
+
+/// Regression for CodeRabbit finding dca7d06a on PR #6689: pinning a
+/// host credential must not leave a copy of its key sitting in a
+/// normally-serialized `ComposioConfig` field. `host_credential` is
+/// `#[serde(skip)]`; before this fix `pin_host_credential` also copied
+/// the key into `api_key`, which is not skipped, so any config save
+/// after pinning persisted the "runtime-only" secret to disk.
+#[test]
+fn pin_host_credential_does_not_leak_the_key_into_serialized_config() {
+ let mut config = ComposioConfig::default();
+ let credential = ComposioHostCredential::direct("sk-pinned-secret-do-not-serialize");
+ config.pin_host_credential(credential);
+
+ assert!(
+ config.api_key.is_none(),
+ "pinning must not populate the serialized api_key field"
+ );
+
+ let serialized = serde_json::to_string(&config).expect("ComposioConfig must serialize");
+ assert!(
+ !serialized.contains("sk-pinned-secret-do-not-serialize"),
+ "{serialized}"
+ );
+ assert!(
+ !serialized.contains("host_credential"),
+ "host_credential is #[serde(skip)] and must never appear: {serialized}"
+ );
+}
+
+/// The pinned-client factory path must still resolve the key from
+/// `host_credential`, not from `api_key` — the field this fix stops
+/// populating.
+#[test]
+fn pinned_client_still_resolves_the_key_from_host_credential() {
+ let mut config = ComposioConfig::default();
+ let credential = ComposioHostCredential::direct("sk-pinned-secret").entity_id("tenant-a");
+ config.pin_host_credential(credential);
+
+ let pinned = config.host_credential.as_ref().expect("credential pinned");
+ assert_eq!(pinned.api_key(), "sk-pinned-secret");
+ assert_eq!(pinned.entity(), "tenant-a");
+}