openai/codex · error · Error

Unsupported platform: ${platform} (${arch})

Error message

Unsupported platform: ${platform} (${arch})

What it means

Thrown while validating a MITM hook's match.query map: a query-parameter key normalized to the empty string. The network proxy validates every network.mitm_hooks entry when config is loaded, and each query key names a concrete query parameter the hook matches, so an empty key cannot mean anything. This particular branch is defensive in practice: normalize_query_name (mitm_hook.rs:581) runs first and rejects an empty name with the identical message, so that site is what you will actually see fire.

Source

Thrown at codex-cli/bin/codex.js:71

    break;
  case "win32":
    switch (arch) {
      case "x64":
        targetTriple = "x86_64-pc-windows-msvc";
        break;
      case "arm64":
        targetTriple = "aarch64-pc-windows-msvc";
        break;
      default:
        break;
    }
    break;
  default:
    break;
}

if (!targetTriple) {
  throw new Error(`Unsupported platform: ${platform} (${arch})`);
}

const platformPackage = PLATFORM_PACKAGE_BY_TARGET[targetTriple];
if (!platformPackage) {
  throw new Error(`Unsupported target triple: ${targetTriple}`);
}

function findCodexExecutable() {
  let vendorRoot;
  try {
    const packageJsonPath = require.resolve(`${platformPackage}/package.json`);
    vendorRoot = path.join(path.dirname(packageJsonPath), "vendor");
  } catch {
    vendorRoot = path.join(__dirname, "..", "vendor");
  }

  const codexExecutable = path.join(
    vendorRoot,

View on GitHub (pinned to 339751715c)

Solutions

  1. Delete the empty-string key from the hook's match.query map
  2. If the entry was meant to constrain a real parameter, restore the name: query = { per_page = ["30"] }
  3. If you build MitmHookConfig in Rust, drop empty keys before serializing: hook.matcher.query.retain(|k, _| !k.is_empty())

Example fix

// config.toml — before
[network]
mitm = true

[[network.mitm_hooks]]
host = "api.github.com"
[network.mitm_hooks.match.query]
"" = ["30"]

// after
[network]
mitm = true

[[network.mitm_hooks]]
host = "api.github.com"
[network.mitm_hooks.match.query]
per_page = ["30"]
Defensive patterns

Strategy: validation

Validate before calling

for hook in &config.mitm_hooks {
    for key in hook.matcher.query.keys() {
        if key.is_empty() {
            return Err(anyhow!("hook for {} has an empty query key", hook.host));
        }
    }
}
validate_mitm_hook_config(&config)?;

Type guard

fn query_keys_valid(hook: &MitmHookConfig) -> bool {
    hook.matcher.query.keys().all(|k| !k.is_empty())
}

Try / catch

match validate_mitm_hook_config(&config) {
    Ok(()) => {}
    Err(err) if err.to_string().contains("query keys must not be empty") => { /* strip offending keys, re-validate */ }
    Err(err) => return Err(err),
}

Prevention

When it happens

Trigger: A config.toml [network] block with mitm = true whose mitm_hooks entry has a match.query map containing an empty key, e.g. query = { "" = ["30"] } (TOML allows a quoted empty key), or a programmatically built MitmHookMatchConfig whose BTreeMap received an empty-string key. validate_mitm_hook_config iterates the map and fails on that key.

Common situations: Template- or script-generated TOML where a placeholder key was never substituted; hand edits that delete a key's name but leave the entry; Rust code inserting computed keys where the computation returned an empty string.

Understand the failure class

Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.

Related errors


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/8740bf31e9f47322. Report an issue: GitHub.