mirror of
https://github.com/openai/codex.git
synced 2026-08-23 13:09:46 +00:00
Test text stringify errors in the code mode runtime (#39505)
## What changed Move circular-value coverage for the `text()` helper from the core integration suite to the in-process code mode runtime tests. Verify that stringification returns no content and surfaces the V8 circular-structure error without needing a mock server or network access. GitOrigin-RevId: d506591af5ae8ce0a8c7305d633a7b0f2e458335
This commit is contained in:
@@ -937,6 +937,47 @@ text(JSON.stringify(returnsUndefined));
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn text_helper_surfaces_stringify_errors() {
|
||||
let service = InProcessCodeModeSession::new();
|
||||
|
||||
let response = execute(
|
||||
&service,
|
||||
ExecuteRequest {
|
||||
source: r#"
|
||||
const circular = {};
|
||||
circular.self = circular;
|
||||
text(circular);
|
||||
"#
|
||||
.to_string(),
|
||||
yield_time_ms: None,
|
||||
..execute_request("")
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
let RuntimeResponse::Result {
|
||||
error_text: Some(error_text),
|
||||
..
|
||||
} = &response
|
||||
else {
|
||||
panic!("circular stringify unexpectedly succeeded: {response:?}");
|
||||
};
|
||||
assert!(
|
||||
error_text.contains("Converting circular structure to JSON"),
|
||||
"unexpected circular stringify error: {error_text}"
|
||||
);
|
||||
let error_text = error_text.clone();
|
||||
assert_eq!(
|
||||
response,
|
||||
RuntimeResponse::Result {
|
||||
cell_id: cell_id("1"),
|
||||
content_items: Vec::new(),
|
||||
error_text: Some(error_text),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn audio_helper_accepts_audio_url_object_and_raw_mcp_audio_block() {
|
||||
let service = InProcessCodeModeSession::new();
|
||||
|
||||
@@ -3686,46 +3686,6 @@ text("after");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn code_mode_surfaces_text_stringify_errors() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = responses::start_mock_server().await;
|
||||
let (_test, second_mock) = run_code_mode_turn(
|
||||
&server,
|
||||
"use exec to return circular text",
|
||||
r#"
|
||||
const circular = {};
|
||||
circular.self = circular;
|
||||
text(circular);
|
||||
"#,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let req = second_mock.single_request();
|
||||
let items = custom_tool_output_items(&req, "call-1");
|
||||
let (_, success) = req
|
||||
.custom_tool_call_output_content_and_success("call-1")
|
||||
.expect("custom tool output should be present");
|
||||
assert_ne!(
|
||||
success,
|
||||
Some(true),
|
||||
"circular stringify unexpectedly succeeded"
|
||||
);
|
||||
assert_eq!(items.len(), 2);
|
||||
assert_regex_match(
|
||||
concat!(
|
||||
r"(?s)\A",
|
||||
r"Script failed\nWall time \d+\.\d seconds\nOutput:\n\z"
|
||||
),
|
||||
text_item(&items, /*index*/ 0),
|
||||
);
|
||||
assert!(text_item(&items, /*index*/ 1).contains("Script error:"));
|
||||
assert!(text_item(&items, /*index*/ 1).contains("Converting circular structure to JSON"));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn code_mode_can_output_images_via_global_helper() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
Reference in New Issue
Block a user