Python SDK: Relative codex_bin overrides pass validation but fail during subprocess launch
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
El error está en resolve_codex_bin en sdk/python/src/openai_codex/client.py, que devuelve un codex_bin relativo sin convertirlo en absoluto, por lo que el posterior lanzamiento del subproceso con un cwd distinto lo resuelve mal. Empieza leyendo esa función y la llamada al subproceso que usa args = [str(codex_bin)]. Está terminado cuando una prueba de regresión en sdk/python/tests/test_artifact_workflow_and_binaries.py, junto a la prueba existente de override explícito del ejecutable, confirma que rutas relativas como ./custom-codex y build/custom-codex se resuelven a rutas absolutas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What issue are you seeing?
The Python SDK accepts a relative path to an explicitly configured Codex executable and verifies that the file exists, but can subsequently fail to launch it with FileNotFoundError.
This affects developers using a local Codex build with a separate workspace configured via CodexConfig.cwd. A second case occurs when a local executable is specified as ./codex: conversion through pathlib.Path removes the leading ./, so the executable is no longer looked up using the explicit relative pathname.
Version and environment
- Source: main at ae21235afbd5ba6556c2ab4b64f6afc96a139ef8. The affected code was rechecked on main before submission.
- Reproduction environment: Linux, CPython 3.13.5.
- No model or API request is needed to reproduce the launch failure.
Steps to reproduce
From a directory containing a locally compiled executable at target/debug/codex (adjust the build path as necessary), run:
from pathlib import Path
from openai_codex import CodexConfig
from openai_codex.client import CodexClient
binary = Path("target/debug/codex")
assert binary.is_file()
workspace = Path("test-workspace").absolute()
workspace.mkdir(exist_ok=True)
client = CodexClient(CodexConfig(
codex_bin="./target/debug/codex",
cwd=str(workspace),
))
try:
client.start()
finally:
client.close()
The binary must be executable, and the workspace should not contain a matching relative build path.
This example illustrates the SDK call path. The actual executed validation used the repository's resolver implementation and a local executable stub, rather than a full Codex build.
Actual behavior
The existence check succeeds, but the subsequent process creation raises:
FileNotFoundError: [Errno 2] No such file or directory: 'target/debug/codex'
An explicitly configured executable such as ./codex-local-repro also fails on POSIX when that executable is not in PATH, even if the parent and child working directories are identical.
Expected behavior
An executable path that passes the SDK's validation should continue to refer to the same file when the SDK launches the subprocess, regardless of the subprocess's configured working directory.
Root cause
In client.py:178–188, resolve_codex_bin checks the path and returns it without making it absolute:
codex_bin = Path(config.codex_bin)
if not ops.path_exists(codex_bin):
raise FileNotFoundError(...)
return codex_bin
In client.py:242–278, the SDK constructs the executable argument using args = [str(codex_bin)] and subsequently launches it with cwd=self.config.cwd.
On POSIX, a relative executable path containing a directory component is interpreted relative to the child working directory. In the single-component case, str(Path("./codex")) produces "codex", losing the explicit relative path notation.
Validation
I ran an isolated reproduction using the exact resolver function body from the repository, temporary executable shell stubs, and Python's actual subprocess API. I then repeated the same cases with the proposed one-line correction.
| Executable configuration | Current resolver | Patched resolver |
|---|---|---|
./codex-local-repro, same cwd, executable absent from PATH |
FileNotFoundError | Launched |
build/codex-local-repro, separate workspace cwd |
FileNotFoundError | Launched |
build/codex-local-repro, unchanged cwd |
Launched | Launched |
| Absolute executable path, separate workspace cwd | Launched | Launched |
All eight behavioral assertions passed. This verifies the resolver-to-subprocess behavior; the full installed SDK, actual Codex CLI and repository integration suite were not run.
Related issues
Searches of existing issues and pull requests for codex_bin, resolve_codex_bin, relative executable paths, and Python SDK startup behavior did not identify a direct duplicate.
Proposed resolution
Make an explicitly configured executable path absolute relative to the calling process before checking its existence and passing it to subprocess creation.
- codex_bin = Path(config.codex_bin)
+ codex_bin = Path(config.codex_bin).absolute()
This preserves the existing parent-directory interpretation used by validation, avoids unnecessarily resolving symbolic links, and leaves bundled executable resolution unchanged. As a workaround, callers can currently pass an absolute codex_bin path.
Add the following regression test alongside the existing explicit executable override test:
@pytest.mark.parametrize(
"relative_path",
["./custom-codex", "build/custom-codex"],
)
def test_relative_codex_bin_returns_absolute_path(
tmp_path, monkeypatch, relative_path
):
from openai_codex import client as client_module
monkeypatch.chdir(tmp_path)
binary = tmp_path / relative_path
binary.parent.mkdir(parents=True, exist_ok=True)
binary.touch()
config = client_module.CodexConfig(codex_bin=relative_path)
assert client_module._resolve_codex_bin(config) == binary
An additional subprocess integration test using an executable stub and a different workspace cwd would cover the actual launch failure. The proposed fix requires no new dependencies.
- Lenguaje dominante
- Rust
- Estrellas
- 136k
- Forks
- 21.6k
- Merge medio
- 1 min
- PR fusionados (30 d)
- 998
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de openai/codex
-
bug CLI performance
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
app bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Windows data plugin feedbackAbiertoapp bug skills windows-os
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
bug CLI TUI
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
openai/codex#63725 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
app bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
Todos los issues de openai/codex
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
qingjian-team/qingjian#1181 ·
Los mantenedores suelen responder en 2 días
-
bug P2: medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
leepokai/Codync#618 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
oxidecomputer/opte#1125 ·
Los mantenedores suelen responder en 2 días
-
[Bug] StreamLifecycleConfig clamps post-TTFT stream timeouts to remaining admission budgetPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
lbjlaq/Antigravity-Manager#4063 ·
Los mantenedores suelen responder en 1 día