Scrub turn git remote URLs in analytics

Remove userinfo, query, and fragment components from associated_remote_urls before turn git workspace metadata is included in analytics events.

Keep git metadata analytics opportunistic: turn completion now reads only metadata that has already been enriched and does not wait for the async git task. Leave existing skill analytics repo_url behavior unchanged.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Ningyi Xie
2026-04-24 23:25:16 -07:00
co-authored by Codex
parent cc694d4907
commit b9cd73dc27
7 changed files with 308 additions and 9 deletions
+36
View File
@@ -47,6 +47,28 @@ async fn build_turn_metadata_header_includes_has_changes_for_clean_repo() {
.output()
.await
.expect("git commit");
Command::new("git")
.args([
"remote",
"add",
"origin",
"https://github.com/openai/codex.git",
])
.current_dir(&repo_path)
.output()
.await
.expect("git remote add");
let expected_head = Command::new("git")
.args(["rev-parse", "HEAD"])
.current_dir(&repo_path)
.output()
.await
.expect("git rev-parse");
let expected_head = String::from_utf8(expected_head.stdout)
.expect("git rev-parse stdout should be utf-8")
.trim()
.to_string();
let header = build_turn_metadata_header(&repo_path, Some("none"))
.await
@@ -59,6 +81,20 @@ async fn build_turn_metadata_header_includes_has_changes_for_clean_repo() {
.cloned()
.expect("workspace");
assert_eq!(
workspace
.get("associated_remote_urls")
.and_then(Value::as_object)
.and_then(|remotes| remotes.get("origin"))
.and_then(Value::as_str),
Some("https://github.com/openai/codex.git")
);
assert_eq!(
workspace
.get("latest_git_commit_hash")
.and_then(Value::as_str),
Some(expected_head.as_str())
);
assert_eq!(
workspace.get("has_changes").and_then(Value::as_bool),
Some(false)
+10 -6
View File
@@ -575,12 +575,16 @@ async fn responses_stream_includes_turn_metadata_header_for_git_workspace_e2e()
.and_then(|workspaces| workspaces.values().next())
.cloned()
.expect("second request should include git workspace metadata");
assert_eq!(
workspace
.get("latest_git_commit_hash")
.and_then(serde_json::Value::as_str),
Some(expected_head.as_str())
);
let actual_head = workspace
.get("latest_git_commit_hash")
.and_then(serde_json::Value::as_str);
if cfg!(windows) {
if let Some(actual_head) = actual_head {
assert_eq!(actual_head, expected_head);
}
} else {
assert_eq!(actual_head, Some(expected_head.as_str()));
}
if let Some(actual_origin) = workspace
.get("associated_remote_urls")
.and_then(serde_json::Value::as_object)