Skip to content

fix: preserve Codex JSON-RPC code - #209

Merged
rapids-bot[bot] merged 1 commit into
NVIDIA:mainfrom
zhongxuanwang-nv:fix/codex-jsonrpc-error-code
Aug 13, 2026
Merged

fix: preserve Codex JSON-RPC code#209
rapids-bot[bot] merged 1 commit into
NVIDIA:mainfrom
zhongxuanwang-nv:fix/codex-jsonrpc-error-code

Conversation

@zhongxuanwang-nv

@zhongxuanwang-nv zhongxuanwang-nv commented Aug 11, 2026

Copy link
Copy Markdown
Member

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

  • Include jsonrpc_code for JsonRpcError failures.
  • Cover a JSON-RPC failure without exposing raw provider data.

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(...) in adapters/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

  • Bug Fixes
    • Improved error details returned for Codex SDK failures by including the applicable JSON-RPC error code.
    • Preserved existing SDK error type and retryability information for clearer troubleshooting.

Signed-off-by: Zhongxuan Wang <daniewang@nvidia.com>
@zhongxuanwang-nv zhongxuanwang-nv added this to the 0.2 milestone Aug 11, 2026
@zhongxuanwang-nv zhongxuanwang-nv self-assigned this Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The Codex adapter now includes the numeric JSON-RPC code in SDK failure metadata for JsonRpcError instances. Tests verify that the error type and code remain available.

Changes

Codex failure metadata

Layer / File(s) Summary
JSON-RPC error handling and validation
adapters/codex/src/nemo_fabric_adapters/codex/adapter.py, tests/adapters/test_codex_adapter.py
The adapter records jsonrpc_code for JsonRpcError failures. The test verifies the error type and numeric code.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title uses valid Conventional Commits syntax and clearly describes preserving the Codex JSON-RPC code.
Description check ✅ Passed The description includes the required overview, reviewer starting point, related issue action keyword, confirmations, and validation details.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@zhongxuanwang-nv
zhongxuanwang-nv marked this pull request as ready for review August 11, 2026 21:43
@zhongxuanwang-nv
zhongxuanwang-nv requested a review from a team as a code owner August 11, 2026 21:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 60ba857 and a1e345b.

📒 Files selected for processing (2)
  • adapters/codex/src/nemo_fabric_adapters/codex/adapter.py
  • tests/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.py
  • adapters/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 spell NVIDIA in all caps; do not use Nvidia, nvidia, nVidia, nVIDIA, or NV.
Use an NVIDIA before a noun, because the name begins with an “en” sound.
Do not add a registered trademark symbol after NVIDIA when 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 with NVIDIA on 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.py
  • adapters/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._native and native artifacts being placed under python/src/nemo_fabric as expected by consumers.

Files:

  • tests/adapters/test_codex_adapter.py
  • adapters/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.py
  • adapters/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 in just test-rust pass and review generated schema diffs.
For schema or public contract changes, run both language suites and review changes under schemas/ and generated API references.

**/*.{rs,py,pyi}: Use snake_case for Rust and Python functions and variables; use PascalCase for 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 both just test-rust and just test-python; otherwise run the test targets for every affected language surface.

Files:

  • tests/adapters/test_codex_adapter.py
  • adapters/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 under tests/adapters, then run just 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, then just test-python; rebuild with just build-python when native code or packaging changes.

Files:

  • tests/adapters/test_codex_adapter.py
  • adapters/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 in python/pyproject.toml.

Files:

  • tests/adapters/test_codex_adapter.py
  • adapters/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.py
  • adapters/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.py
  • adapters/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.asyncio to tests; async tests are automatically detected by the async runner.
Do not add -> None return type annotations to test functions.
When mocking a class, use unittest.mock.MagicMock or AsyncMock, using the spec argument when necessary, rather than defining a new class.
Prefix mocked class names with mock, not fake.
Prefer pytest fixtures over helper methods.
If a fixture is needed in multiple test files, define it once in conftest.py rather than repeating it.
Define fixtures using @pytest.fixture(name="<fixture_name>"[, scope="<scope>"]) and a <fixture_name>_fixture function; specify scope only when it is not function.
Prefer pytest.mark.parametrize over separate tests for different input types.
Use @pytest.mark.usefixtures when 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 using results["data"] instead of results.get("data").
When adapter installation metadata changes, packaging metadata tests must directly assert that the root project depends unconditionally on the exact-version nemo-fabric-runtime distribution.
Packaging metadata tests must verify that each root harness extra delegates to the matching version of the leaf adapter's harness extra.
Packaging metadata tests must verify that bare leaf dependencies remain adapter-owned and that the root adapter-tests dependency group installs each leaf through its harness extra.
Packaging metadata tests must verify that every leaf provides full; only adapters importing NeMo Relay Python APIs provide relay, while adapters using an external Relay executable have full equal to harness.

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.py
  • adapters/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.py
  • adapters/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.py
  • adapters/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 exercising plan, doctor, and run.
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.py
  • adapters/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>/ with LICENSE -> ../../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 public nemo-fabric-build-adapter skill 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, consulting adapters/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, and adapters from 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!

Comment thread tests/adapters/test_codex_adapter.py
@zhongxuanwang-nv

Copy link
Copy Markdown
Member Author

/merge

@rapids-bot
rapids-bot Bot merged commit a3a47c4 into NVIDIA:main Aug 13, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants