SIGN IN SIGN UP

bindings/rust: report real statuses instead of collapsing them to backend (#2114)

## What?

Makes the Rust bindings report the status NIXL actually returned,
instead of
collapsing every non-success to `BACKEND`.

- adds `NIXL_CAPI_ERROR_NOT_FOUND` to the C API status enum
- teaches `nixl_capi_status_from_nixl_status` to map
`NIXL_ERR_NOT_FOUND` and
  `NIXL_ERR_INVALID_PARAM`, which previously fell through to `BACKEND`
- routes through that mapper every wrapper whose status the bindings
surface,
  replacing the hand-rolled `ret == NIXL_SUCCESS ? SUCCESS : BACKEND`
- adds `NixlError::NotFound` and the matching arms on the agent methods

## Why?

The mapper knew only `SUCCESS`, `IN_PROG` and `NO_TELEMETRY`, so a
caller could
not tell "peer metadata not loaded yet", which is retryable, from a real
fault,
which is fatal. `nixl_agent.cpp` returns `NIXL_ERR_NOT_FOUND` from
roughly two
dozen sites, most of them on the connect path, and all of them reached
Rust as
`BackendError`. The `InvalidParam` arms already written in the bindings
were
unreachable for the same reason.

This matters for callers that retry: with only `BackendError` to go on,
a
transport either retries everything, including genuine failures, or
nothing.

## How?

**One behaviour change to be aware of.** An unknown remote agent now
yields
`NotFound` where it used to yield `BackendError`. `getXferTelemetry`
shares the
mapper and is affected the same way. This follows the C++ side rather
than
changing it. `test_prep_xfer_dlist_invalid_agent` is updated to match —
its
message already said `InvalidParam` while asserting `BackendError`.

**Some paths lost the status even after the wrapper was routed**, and
are fixed
here too:

- `get_local_partial_md` and `query_xfer_backend` returned `BACKEND`
from their
`ret != NIXL_SUCCESS` guard, so the mapper call at the end only ever saw
  `NIXL_SUCCESS`
- `post_xfer_req` and `get_xfer_status` hand-rolled
`SUCCESS`/`IN_PROG`/`BACKEND`;
  the mapper already maps `IN_PROG`
- `send_local_md`, `fetch_remote_md`, `invalidate_local_md`,
`send_notification`
  and `get_xfer_telemetry` had no `NotFound` arm on the Rust side
- `invalidate_remote_md` and `invalidate_all_remotes` discarded the
status and
returned `Ok(())`, and dropped the remote from local tracking before the
  agent had invalidated it, so a failure lost it
- `get_local_md` checked `data.is_null()` before matching the status, so
every
  error returned `InvalidDataPointer`
- `prep_xfer_dlist` leaked the handle it allocates when `prepXferDlist`
fails

`check_remote_md` is deliberately unchanged: it returns `bool`, and
`NOT_FOUND`
already means `false` there, which is what a presence probe should
report.

`prep_mem_view_local` and `_remote`, merged in #2060, already call the
mapper,
so they pick up a `NotFound` arm here. Their unknown-agent and
all-null-agent
tests asserted only `is_err()` because `NOT_FOUND` had nowhere to map;
both now
assert `NotFound`, which is what `nixl_agent.cpp` returns for a remote
agent
whose metadata is not loaded and for a list with no addressable peer.

The repeated `InvalidParam`/`NotFound`/`_` arms this leaves behind are
worth
folding into one helper. That is a pure refactor across files this PR
does not
otherwise touch, so it follows separately.

## Testing

104 tests pass with `cargo test -- --test-threads=1` — 96 in `tests.rs`,
4 in
`mem_view.rs`, 4 in `test_sync_manager.rs` — on UCX 1.21 with a CUDA
device,
against `libnixl` built from this branch's base. The two memory-view
tests that
assert `NotFound` run by default; they need a GPU but no device-capable
RDMA
lane.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Improved error reporting for unavailable agents, metadata, backends,
and telemetry.
* Invalid parameters and missing resources now return specific,
actionable errors instead of generic failures or false success.
* Remote metadata invalidation now reports failures accurately and stops
when an error occurs.
* Transfer and memory operations provide more consistent status handling
across the API.

* **Tests**
* Updated coverage to verify precise “not found” and invalid-parameter
error results.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Shahaf Kiselnik <smeir@nvidia.com>
S
ShahafMeir committed
dd54dee0492ae15c539647dc315a150553564a50
Parent: d815856
Committed by GitHub <noreply@github.com> on 8/20/2026, 7:00:34 AM