diff --git a/src/handlers/handler.rs b/src/handlers/handler.rs index 73c62ee..bbf1920 100644 --- a/src/handlers/handler.rs +++ b/src/handlers/handler.rs @@ -26,7 +26,6 @@ pub struct Meta { pub start: StartFrom, pub return_options: Option, pub modules: Option>, // module_name -> frame_id - pub with_env: Option>, // env_var -> frame_id } #[derive(Clone, Debug, Serialize, Deserialize, Default)] @@ -107,36 +106,6 @@ impl Handler { } } - // Handle environment variables if specified - if let Some(env_vars) = &meta.with_env { - for (var_name, frame_id) in env_vars { - // Parse frame ID - let id = Scru128Id::from_str(frame_id) - .map_err(|e| format!("Invalid env var frame ID '{}': {}", frame_id, e))?; - - // Get frame - let env_frame = store - .get(&id) - .ok_or_else(|| format!("Env var frame '{}' not found", frame_id))?; - - // Get content from CAS - let hash = env_frame - .hash - .as_ref() - .ok_or_else(|| format!("Env var frame '{}' has no content hash", frame_id))?; - - let content = store - .cas_read(hash) - .await - .map_err(|e| format!("Failed to read env var content: {}", e))?; - - let content = String::from_utf8(content) - .map_err(|e| format!("Env var content is not valid UTF-8: {}", e))?; - - engine = engine.with_env_vars([(var_name.clone(), content)])?; - } - } - let closure = engine.parse_closure(&expression)?; let block = engine.state.get_block(closure.block_id); diff --git a/src/handlers/tests.rs b/src/handlers/tests.rs index 24ae4e5..974cca4 100644 --- a/src/handlers/tests.rs +++ b/src/handlers/tests.rs @@ -581,63 +581,6 @@ async fn test_handler_with_module() -> Result<(), Error> { Ok(()) } -#[tokio::test] -async fn test_handler_with_env() -> Result<(), Error> { - let (store, _temp_dir) = setup_test_environment().await; - let options = ReadOptions::builder().follow(FollowOption::On).build(); - let mut recver = store.read(options).await; - assert_eq!(recver.recv().await.unwrap().topic, "xs.threshold"); - - // Create a frame with some content for the env var - let env_frame = store.append( - Frame::with_topic("env-content") - .hash(store.cas_insert("hello world").await?) - .build(), - ); - assert_eq!(recver.recv().await.unwrap().topic, "env-content"); - - // Create handler that uses the env var - let frame_handler = store.append( - Frame::with_topic("test.register") - .hash( - store - .cas_insert( - r#"{|frame| - if $frame.topic != "trigger" { return } - $env.TEST_VAR - }"#, - ) - .await?, - ) - .meta(serde_json::json!({ - "with_env": { - "TEST_VAR": env_frame.id.to_string() - } - })) - .build(), - ); - - // Wait for handler registration - assert_eq!(recver.recv().await.unwrap().topic, "test.register"); - assert_eq!(recver.recv().await.unwrap().topic, "test.registered"); - - // Send trigger frame - let trigger = store.append(Frame::with_topic("trigger").build()); - assert_eq!(recver.recv().await.unwrap().topic, "trigger"); - - // Get handler output - let output = recver.recv().await.unwrap(); - validate_handler_output_frame!(&output, "test.out", frame_handler, trigger, None); - - // Verify output content shows the env var value - let content = store.cas_read(&output.hash.unwrap()).await?; - let result = String::from_utf8(content)?; - assert_eq!(result, r#""hello world""#); - - assert_no_more_frames(&mut recver).await; - Ok(()) -} - #[tokio::test] async fn test_handler_preserve_env() -> Result<(), Error> { let (store, _temp_dir) = setup_test_environment().await;