Ignore non-JSON files in plugin catalog test helpers (#42126)

## What changed

Restrict cached remote plugin catalog test helpers to `.json` files when
reading plugin IDs or rewriting `fetched_at` timestamps.

GitOrigin-RevId: a144f44a8adc26a8d0aa0d85e95c8fe0366e8aa0
This commit is contained in:
willwang-openai
2026-09-01 20:18:10 +00:00
committed by copyberry
parent 0276f2ee55
commit 7730edf62c
@@ -5134,6 +5134,9 @@ fn cached_remote_catalog_plugin_ids(codex_home: &std::path::Path) -> Result<Vec<
let mut plugin_ids = Vec::new();
for entry in std::fs::read_dir(cache_dir)? {
let path = entry?.path();
if path.extension().is_none_or(|ext| ext != "json") {
continue;
}
let cached_catalog: serde_json::Value = serde_json::from_slice(&std::fs::read(path)?)?;
let Some(plugins) = cached_catalog["plugins"].as_array() else {
continue;
@@ -5156,6 +5159,9 @@ fn rewrite_cached_remote_catalog_fetched_at(
let cache_dir = codex_home.join("cache/remote_plugin_catalog");
for entry in std::fs::read_dir(cache_dir)? {
let path = entry?.path();
if path.extension().is_none_or(|ext| ext != "json") {
continue;
}
let mut cached_catalog: serde_json::Value = serde_json::from_slice(&std::fs::read(&path)?)?;
cached_catalog["fetched_at"] = serde_json::json!(fetched_at);
std::fs::write(path, serde_json::to_vec_pretty(&cached_catalog)?)?;