The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(attachments): treat data URIs containing url text as inline media
Steven Enamakel0d296c06463a
diff --git a/crates/openhuman-core/src/attachments/provider_history_tests.rs b/crates/openhuman-core/src/attachments/provider_history_tests.rsindex 90b38cc22c..1be0abd6cd 100644--- a/crates/openhuman-core/src/attachments/provider_history_tests.rs+++ b/crates/openhuman-core/src/attachments/provider_history_tests.rs@@ -47,6 +47,10 @@ async fn missing_historical_media_does_not_block_latest_valid_media() {mime_type: Some("image/png".into()),})}));+ old_content.push(ContentBlock::Document(MediaRef::Url {+ url: "ftp://docs.example.test/old.pdf?signature=document-private".into(),+ media_type: Some("application/pdf".into()),+ }));let old_user = Message::User(tinyinference_llm::message::UserMessage {content: old_content,});@@ -69,6 +73,9 @@ async fn missing_historical_media_does_not_block_latest_valid_media() {assert!(!serde_json::to_string(history).unwrap().contains("also-private"));+ assert!(!serde_json::to_string(history)+ .unwrap()+ .contains("document-private"));let durable_text = serde_json::to_string(&durable).unwrap();assert!(signed_urls.iter().all(|url| durable_text.contains(url)));assert!(serde_json::to_string(&captured[0].messages[1])diff --git a/crates/openhuman-core/src/attachments/provider_owner.rs b/crates/openhuman-core/src/attachments/provider_owner.rsindex c7d68cbf7e..458707231a 100644--- a/crates/openhuman-core/src/attachments/provider_owner.rs+++ b/crates/openhuman-core/src/attachments/provider_owner.rs@@ -77,7 +77,8 @@ impl MediaSourceResolver<AttachmentAccessScope> for AttachmentModel {max_bytes: usize,mime_hint: Option<&str>,) -> Result<ResolvedMedia, String> {- if source.contains("://")+ if !source.starts_with("data:")+ && source.contains("://")&& !source.starts_with("http://")&& !source.starts_with("https://"){@@ -291,9 +292,7 @@ fn history_source_block(modality: InputModality, source: &str) -> ContentBlock {mime_type: None,}),modality => {- let media = if source.starts_with("data:")- || source.starts_with("http://")- || source.starts_with("https://")+ let media = if source.starts_with("data:") || source.contains("://"){MediaRef::Url {url: source.to_owned(),diff --git a/crates/openhuman-core/src/attachments/provider_routing_tests.rs b/crates/openhuman-core/src/attachments/provider_routing_tests.rsindex 9c964401ef..0b43820894 100644--- a/crates/openhuman-core/src/attachments/provider_routing_tests.rs+++ b/crates/openhuman-core/src/attachments/provider_routing_tests.rs@@ -539,8 +539,8 @@ fn secure_open_rejects_invalid_paths_and_reads_authorized_absolute_paths() {#[tokio::test]async fn unsupported_media_urls_and_oversized_inline_sources_fail_before_inference() {let temp = tempfile::tempdir().unwrap();- let config = offline_config(temp.path());let transport = Arc::new(CaptureModel::new(vec![]));+ let config = offline_config(temp.path());let model = controlled_wrapper(transport.clone(), config, &[]);let unsupported = user_request(vec![ContentBlock::Document(MediaRef::Url {@@ -550,16 +550,47 @@ async fn unsupported_media_urls_and_oversized_inline_sources_fail_before_inferenlet error = model.invoke(&(), unsupported).await.unwrap_err();assert!(error.to_string().contains("unsupported media URL scheme"));- // Leave room for a data-URI header while still proving an oversized body- // is rejected before the owner resolver or inference transport runs.- let max_encoded_bytes = 50 * 1024 * 1024 * 4 / 3 + 4097;+ // The host guard rejects encoded data larger than its configured limit+ // (including room for the data-URI header) before calling the resolver.+ let mut small_limit = (*offline_config(temp.path())).clone();+ small_limit.multimodal_files.max_file_size_mb = 1;+ let model = controlled_wrapper(transport.clone(), Arc::new(small_limit), &[]);+ let max_encoded_bytes = 1024 * 1024 * 4 / 3 + 4097;let oversized = user_request(vec![ContentBlock::Document(MediaRef::Base64 {data: "A".repeat(max_encoded_bytes + 1),media_type: "application/octet-stream".into(),})]);let error = model.invoke(&(), oversized).await.unwrap_err();- assert!(error- .to_string()- .contains("attachment exceeds configured file limit"));+ assert!(error.to_string().contains("attachment exceeds configured file limit"));++ // A valid base64 body just over the decoded byte limit must also fail+ // before legacy materialization or inference.+ let decoded_oversize_len = ((1024 * 1024 + 1 + 2) / 3) * 4;+ let decoded_oversized = user_request(vec![ContentBlock::Document(MediaRef::Base64 {+ data: "A".repeat(decoded_oversize_len),+ media_type: "text/plain".into(),+ })]);+ let error = model.invoke(&(), decoded_oversized).await.unwrap_err();+ assert!(error.to_string().to_lowercase().contains("limit"));assert!(transport.requests.lock().unwrap().is_empty());+ assert!(!temp.path().join("uploads/legacy-media").exists());+}++#[tokio::test]+async fn data_uri_payload_containing_a_url_is_not_treated_as_a_remote_source() {+ let temp = tempfile::tempdir().unwrap();+ let config = offline_config(temp.path());+ let transport = Arc::new(CaptureModel::new(vec![]));+ let model = controlled_wrapper(transport.clone(), config, &[]);+ let request = user_request(vec![ContentBlock::Document(MediaRef::Url {+ url: "data:text/plain,https://files.invalid/reference".into(),+ media_type: Some("text/plain".into()),+ })]);++ model.invoke(&(), request).await.unwrap();+ let captured = transport.requests.lock().unwrap();+ assert_eq!(captured.len(), 1);+ assert!(captured[0].1.messages[0]+ .text()+ .contains("https://files.invalid/reference"));}