fix: preserve Codex JSON-RPC code - #209
Conversation
Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
WalkthroughThe Codex adapter now includes the numeric JSON-RPC code in SDK failure metadata for ChangesCodex failure metadata
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/adapters/test_codex_adapter.py`:
- Around line 714-720: Update test_sdk_failure_preserves_jsonrpc_code to
construct JsonRpcError with a non-empty data value while retaining the exact
output["error"]["metadata"] assertion, confirming provider payloads are excluded
from metadata.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: b3378a98-6929-46d4-9a0d-c34aac58304c
📒 Files selected for processing (2)
adapters/codex/src/nemo_fabric_adapters/codex/adapter.pytests/adapters/test_codex_adapter.py
📜 Review details
⏰ Context from checks skipped due to timeout. (19)
- GitHub Check: Test (arm64)
- GitHub Check: Test (x86_64)
- GitHub Check: Test (Python 3.13, linux-amd64)
- GitHub Check: Test (Python 3.11, windows-amd64)
- GitHub Check: Test (Python 3.12, linux-arm64)
- GitHub Check: Test (Python 3.13, macos-arm64)
- GitHub Check: Test (Python 3.14, macos-arm64)
- GitHub Check: Test (Python 3.13, linux-arm64)
- GitHub Check: Test (Python 3.14, linux-arm64)
- GitHub Check: Test (Python 3.12, windows-amd64)
- GitHub Check: Test (Python 3.11, macos-arm64)
- GitHub Check: Test (Python 3.12, macos-arm64)
- GitHub Check: Test (Python 3.12, linux-amd64)
- GitHub Check: Test (Python 3.13, windows-amd64)
- GitHub Check: Test (Python 3.14, windows-amd64)
- GitHub Check: Test (Python 3.11, linux-amd64)
- GitHub Check: Test (Python 3.11, linux-arm64)
- GitHub Check: Test (Python 3.14, linux-amd64)
- GitHub Check: Pre-commit
🧰 Additional context used
📓 Path-based instructions (22)
**/*.{rs,py,pyi,json,yaml,yml}
📄 CodeRabbit inference engine (.agents/skills/contribute-api/SKILL.md)
Determine and update every affected public surface, including the CLI, PyO3 bindings, Python SDK, type stubs, schemas, and adapter contract, so they remain in parity.
Files:
tests/adapters/test_codex_adapter.pyadapters/codex/src/nemo_fabric_adapters/codex/adapter.py
**/*
📄 CodeRabbit inference engine (.agents/skills/karpathy-guidelines/SKILL.md)
**/*: Before implementing, explicitly state assumptions, surface ambiguity and tradeoffs, present multiple interpretations when relevant, and ask for clarification rather than silently deciding or proceeding when requirements are unclear.
Prefer the minimum code needed to solve the requested problem: avoid speculative features, unnecessary abstractions, unrequested flexibility, and handling of impossible scenarios; simplify overcomplicated solutions.
When editing existing code, make surgical changes only: do not modify unrelated code, comments, formatting, or pre-existing dead code; match the existing style, and remove only unused imports, variables, or functions introduced by your changes.
Define verifiable success criteria for each task, such as writing regression tests for bugs and invalid-input tests for validation, then verify the implementation against those criteria. For multi-step work, state a brief plan with a verification check for each step.
**/*: Always spellNVIDIAin all caps; do not useNvidia,nvidia,nVidia,nVIDIA, orNV.
Usean NVIDIAbefore a noun, because the name begins with an “en” sound.
Do not add a registered trademark symbol afterNVIDIAwhen referring to the company; use trademark symbols with product names only when required by the document type or legal guidance.
Verify official capitalization, spacing, hyphenation, and spelling for NVIDIA and third-party product names; do not rewrite official product names for grammar or title-case rules.
Precede NVIDIA product names withNVIDIAon first mention when natural and accurate, and link the first mention when the destination helps the reader.
On first use, include the company name and full model qualifier when it helps identify the model; preserve official capitalization and punctuation, and use shorter family names only after establishing the full name.
For learning-oriented and developer content, do not force trademark symbols unless explicitly required; for press, ...
Files:
tests/adapters/test_codex_adapter.pyadapters/codex/src/nemo_fabric_adapters/codex/adapter.py
**/*.{rs,py}
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
For native binding changes, run
cargo check -p fabric-python --locked.Keep package names, import paths, and module names internally consistent, including the editable maturin build producing
nemo_fabric._nativeand native artifacts being placed underpython/src/nemo_fabricas expected by consumers.
Files:
tests/adapters/test_codex_adapter.pyadapters/codex/src/nemo_fabric_adapters/codex/adapter.py
**/*.{py,pyi}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If Python code or a Python-facing adapter changes, run
just test-python.Use type annotations for public Python APIs and keep native binding declarations synchronized with their Rust implementations.
Files:
tests/adapters/test_codex_adapter.pyadapters/codex/src/nemo_fabric_adapters/codex/adapter.py
**/*.{rs,py,pyi}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
**/*.{rs,py,pyi}: If public configuration types change, confirm schema snapshot tests injust test-rustpass and review generated schema diffs.
For schema or public contract changes, run both language suites and review changes underschemas/and generated API references.
**/*.{rs,py,pyi}: Usesnake_casefor Rust and Python functions and variables; usePascalCasefor Rust types and Python classes.
Run tests for every affected language surface. Changes touching the Rust core or public schemas require both Rust and Python test suites.
Use the existing style in the Python SDK, adapters, examples, and tests, and maintain synchronization between native Python binding declarations and Rust implementations.
If a change touches the Rust core or public schemas, run bothjust test-rustandjust test-python; otherwise run the test targets for every affected language surface.
Files:
tests/adapters/test_codex_adapter.pyadapters/codex/src/nemo_fabric_adapters/codex/adapter.py
tests/adapters/**/*.py
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
tests/adapters/**/*.py: If an adapter or integration changes, run its focused tests.
For adapter behavior changes, run focused adapter tests undertests/adapters, then runjust test-python.
Files:
tests/adapters/test_codex_adapter.py
**/*.{py,pyi,rs}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
For Python SDK or PyO3 binding changes, use
python-tests, run focused pytest tests first, thenjust test-python; rebuild withjust build-pythonwhen native code or packaging changes.
Files:
tests/adapters/test_codex_adapter.pyadapters/codex/src/nemo_fabric_adapters/codex/adapter.py
**/*.{rs,py,toml}
📄 CodeRabbit inference engine (.agents/skills/update-project-version/SKILL.md)
When editing version helpers, verify every
nemo-fabric-*workspace package through Cargo metadata and reject a static version inpython/pyproject.toml.
Files:
tests/adapters/test_codex_adapter.pyadapters/codex/src/nemo_fabric_adapters/codex/adapter.py
**/*.{toml,rs,py}
📄 CodeRabbit inference engine (.agents/skills/update-project-version/SKILL.md)
Avoid blind repository-wide replacement of version-like strings; distinguish package-version references from examples and unrelated dependency versions.
Files:
tests/adapters/test_codex_adapter.pyadapters/codex/src/nemo_fabric_adapters/codex/adapter.py
**/*.{md,mdx,yml,py,rs,sh}
📄 CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)
Keep documentation aligned with current NeMo Fabric behavior, repository layout, entry points, commands, package names, APIs, bindings, and support claims.
Files:
tests/adapters/test_codex_adapter.pyadapters/codex/src/nemo_fabric_adapters/codex/adapter.py
tests/**/*.py
📄 CodeRabbit inference engine (.agents/skills/python-tests/SKILL.md)
tests/**/*.py: Use pytest to run Python tests.
Do not add@pytest.mark.asyncioto tests; async tests are automatically detected by the async runner.
Do not add-> Nonereturn type annotations to test functions.
When mocking a class, useunittest.mock.MagicMockorAsyncMock, using thespecargument when necessary, rather than defining a new class.
Prefix mocked class names withmock, notfake.
Prefer pytest fixtures over helper methods.
If a fixture is needed in multiple test files, define it once inconftest.pyrather than repeating it.
Define fixtures using@pytest.fixture(name="<fixture_name>"[, scope="<scope>"])and a<fixture_name>_fixturefunction; specifyscopeonly when it is notfunction.
Preferpytest.mark.parametrizeover separate tests for different input types.
Use@pytest.mark.usefixtureswhen a fixture is needed but its returned value is unused or it returns no value.
Avoid defensive programming in tests; access expected values directly so missing data raises a clear failure, such as usingresults["data"]instead ofresults.get("data").
When adapter installation metadata changes, packaging metadata tests must directly assert that the root project depends unconditionally on the exact-versionnemo-fabric-runtimedistribution.
Packaging metadata tests must verify that each root harness extra delegates to the matching version of the leaf adapter'sharnessextra.
Packaging metadata tests must verify that bare leaf dependencies remain adapter-owned and that the rootadapter-testsdependency group installs each leaf through itsharnessextra.
Packaging metadata tests must verify that every leaf providesfull; only adapters importing NeMo Relay Python APIs providerelay, while adapters using an external Relay executable havefullequal toharness.
Files:
tests/adapters/test_codex_adapter.py
tests/**/*.{rs,py,pyi}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
When adding functionality, include tests in the corresponding Rust crate or in the relevant area under
tests/.
Files:
tests/adapters/test_codex_adapter.py
**/*.{rs,py,pyi,json}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Public contract changes must keep checked-in JSON Schema snapshots and native Python binding declarations synchronized.
Files:
tests/adapters/test_codex_adapter.pyadapters/codex/src/nemo_fabric_adapters/codex/adapter.py
**/*.{rs,py,html,md,mdx,toml,yaml,yml,sh,bash}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
All source files must include the appropriate SPDX copyright and Apache-2.0 license headers using the comment syntax for their file type; MDX files must use a JSX comment.
Files:
tests/adapters/test_codex_adapter.pyadapters/codex/src/nemo_fabric_adapters/codex/adapter.py
{adapters/*/fabric-adapter.json,adapters/*/**,tests/adapters/**,docs/**,catalogs/**,share/nemo-fabric/adapters/**}
📄 CodeRabbit inference engine (.agents/skills/contribute-adapter/SKILL.md)
Keep descriptor claims, implementation, focused tests, public documentation, catalog entries, and packaged metadata synchronized, starting with the narrowest truthful capability set.
Files:
tests/adapters/test_codex_adapter.pyadapters/codex/src/nemo_fabric_adapters/codex/adapter.py
tests/adapters/test_*.py
📄 CodeRabbit inference engine (.agents/skills/contribute-adapter/SKILL.md)
tests/adapters/test_*.py: Include a subprocess test of the packaged entry point, exact descriptor assertions for every claimed capability, and a credential-free fixture exercisingplan,doctor, andrun.
Keep credentialed live-target tests opt-in and provide deterministic CI coverage.
Files:
tests/adapters/test_codex_adapter.py
**/*.{md,mdx,rst,yml,yaml,py,sh}
📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)
**/*.{md,mdx,rst,yml,yaml,py,sh}: Keep package names, repository references, and build commands current.
Ensure example commands match current package names and paths.
Files:
tests/adapters/test_codex_adapter.pyadapters/codex/src/nemo_fabric_adapters/codex/adapter.py
{tests/**,python/tests/**}
⚙️ CodeRabbit configuration file
{tests/**,python/tests/**}: Tests should cover the behavior promised by the changed API surface, including error paths, lifecycle cleanup, and SDK/native parity where relevant.
Files:
tests/adapters/test_codex_adapter.py
adapters/*/
📄 CodeRabbit inference engine (.agents/skills/contribute-adapter/SKILL.md)
Place each first-party adapter under
adapters/<name>/withLICENSE -> ../../LICENSE,README.md,fabric-adapter.json, language-native package and lock files, a source entry point, and focused tests.
Files:
adapters/codex/src/nemo_fabric_adapters/codex/adapter.py
adapters/*/**
📄 CodeRabbit inference engine (.agents/skills/contribute-adapter/SKILL.md)
adapters/*/**: Use the publicnemo-fabric-build-adapterskill for adapter-contract semantics, descriptor design, configuration mapping, lifecycle behavior, and conformance evidence.
Use the closest shared first-party host pattern with the same target boundary, consultingadapters/common/and the closest matching adapter.
Files:
adapters/codex/src/nemo_fabric_adapters/codex/adapter.py
{docs,examples,adapters}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-code-freeze/SKILL.md)
Update appropriate current-version installation, package, and configuration examples under
docs,examples, andadaptersfrom the old version to<next-version>, while preserving release notes, changelogs, generated output, and third-party attribution references.
Files:
adapters/codex/src/nemo_fabric_adapters/codex/adapter.py
{adapters/**,examples/**}
⚙️ CodeRabbit configuration file
{adapters/**,examples/**}: Review adapter and example changes for command correctness, config/schema consistency, artifact handling, and compatibility with the public NeMo Fabric contracts.
Files:
adapters/codex/src/nemo_fabric_adapters/codex/adapter.py
🧠 Learnings (1)
📚 Learning: 2026-07-09T22:28:51.689Z
Learnt from: AjayThorve
Repo: NVIDIA/NeMo-Fabric PR: 43
File: adapters/claude-sdk/src/nemo_fabric_adapters/claude_sdk/adapter.py:164-168
Timestamp: 2026-07-09T22:28:51.689Z
Learning: In the NeMo-Fabric adapters, treat path values used in Fabric adapter configuration (including logic like `_resolve_path` in adapter.py) as config-root-relative. Do not apply `Path.expanduser()` (or otherwise apply `~`/home or shell-style expansion), because it will make the resolved paths normalize inconsistently across adapters. Also, do not rely on or add any resolution behavior that uses `harness.settings.cwd` as an override point for these adapter paths—`harness.settings.cwd` is explicitly unsupported in this adapter context.
Applied to files:
adapters/codex/src/nemo_fabric_adapters/codex/adapter.py
🔇 Additional comments (3)
adapters/codex/src/nemo_fabric_adapters/codex/adapter.py (2)
25-25: LGTM!
797-804: LGTM!tests/adapters/test_codex_adapter.py (1)
16-16: LGTM!
|
/merge |
Overview
Codex SDK JSON-RPC failures expose a numeric RPC code. Fabric retained the exception type and retryability but dropped that safe diagnostic.
Retain the numeric code in the existing structured error metadata. Raw SDK messages and data remain excluded because they can contain provider payloads. No request, lifecycle, retry, or provider behavior changes.
Details
jsonrpc_codeforJsonRpcErrorfailures.Validation
pytest -q tests/adapters/test_codex_adapter.py— 47 passed.just test-python— 741 passed, 55 skipped.ruff==0.15.21 check adapters/codex/src/nemo_fabric_adapters/codex/adapter.py tests/adapters/test_codex_adapter.py— passed.git diff --check— passed.Where should the reviewer start?
Start with
sdk_failure(...)inadapters/codex/src/nemo_fabric_adapters/codex/adapter.py; the adjacent regression test shows the only new public field.Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Relates to FABRIC-185.
I confirm this contribution is my own work, or I have the right to submit it under this project's license.
I searched existing issues and open pull requests, and this does not duplicate existing work.
Summary by CodeRabbit