BigPizzaV3/CodexPlusPlus · error · anyhow::Error

No injectable Codex page target found

Error message

No injectable Codex page target found

What it means

Thrown by `pick_injectable_codex_page_target` when no injectable page target matches any of the Codex-specific priority predicates (exact Codex app main target, primary Codex app target, etc.). Unlike `pick_page_target`, this requires the target to actually look like the Codex app page.

Solutions

  1. Open or re-focus the Codex app page in the embedded browser so a matching target exists
  2. Fall back to `pick_page_target` if any injectable page is acceptable for your use case
  3. Re-run `list_targets` first — the target list may be stale relative to the current browser state
  4. Verify the page's URL/title against the `is_codex_app_page_target` predicates to see why your page doesn't match

Example fix

// before
let target = cdp::pick_injectable_codex_page_target(&targets)?; // codex tab closed
// after
let target = match cdp::pick_injectable_codex_page_target(&targets) {
    Ok(t) => t,
    Err(_) => cdp::pick_page_target(&targets)?, // lenient fallback
};
Defensive patterns

Strategy: fallback

Validate before calling

fn has_codex_page(targets: &[CdpTarget]) -> bool {
    targets.iter().any(|t| t.target_type == "page" && t.url.contains("codex"))
}

Try / catch

let target = match cdp::pick_injectable_codex_page_target(&targets) {
    Ok(t) => t,
    Err(_) => cdp::pick_page_target(&targets).context("no Codex page open; open the app tab first")?,
};

Prevention

When it happens

Trigger: Calling `pick_injectable_codex_page_target` when the target list contains only non-Codex pages (other sites, embedded browser pages that merely have 'codex' in their title but are classified as embedded/standalone, or non-page targets).

Common situations: The Codex app tab isn't open yet in the embedded browser, the user navigated the Codex tab away to another URL, or the app window was closed so only unrelated pages remain.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/4404b40a0e74a04b. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/cdp.rs:270

    bail!("No injectable page target found")
}

pub fn pick_injectable_codex_page_target(targets: &[CdpTarget]) -> anyhow::Result<CdpTarget> {
    let priorities: [fn(&CdpTarget) -> bool; 4] = [
        is_exact_codex_app_main_target,
        is_primary_codex_app_target,
        is_chatgpt_desktop_page_target,
        is_supported_codex_page_target,
    ];
    for matches_priority in priorities {
        if let Some(target) = targets
            .iter()
            .find(|target| is_injectable_page_target(target) && matches_priority(target))
        {
            return Ok(target.clone());
        }
    }
    bail!("No injectable Codex page target found")
}

fn is_codex_app_page_target(target: &CdpTarget) -> bool {
    let Ok(url) = reqwest::Url::parse(target.url.trim()) else {
        return false;
    };
    url.scheme().eq_ignore_ascii_case("app")
        && url.host_str() == Some("-")
        && url.path().eq_ignore_ascii_case("/index.html")
}

pub fn is_injectable_page_target(target: &CdpTarget) -> bool {
    target.target_type == "page"
        && target
            .web_socket_debugger_url
            .as_deref()
            .is_some_and(|url| !url.is_empty())
}

View on GitHub (pinned to b1ed92e5e4)