HyukjinKwon opened a new pull request, #915:
URL: https://github.com/apache/spark-connect-rust/pull/915

   ### What changes were proposed in this pull request?
   
   PySpark's client reads the `grpc-status-details-bin` of a failure in three 
places:
   - `rpc_status.from_call`;
   - the `Any.Unpack` of the first `ErrorInfo` in `_handle_rpc_error`;
   - that of the first `RetryInfo` in `DefaultPolicy`.
   
   In each, upb parses the details. In the grpcio dialect of the Python client, 
the drop-in now reads them as upb does: the same class, text, chain and point 
of PySpark's error.
   
   - **upb's limit.** A `google.rpc.Status` read past upb's limit of 100 levels 
raises protobuf's `DecodeError` (`Error parsing message with type 
'google.rpc.Status': Wire format was corrupt`), whatever its code and message, 
with or without an `ErrorInfo`. That covers 101 nested groups of a field the 
type does not know, or 100 inside a detail, which is a level of its own. With 
`SetAllowOversizeProtos(True)`, the limit is 65535.
     - Before, the drop-in raised the `SparkConnectGrpcException` of the code 
and message of the call, or grpc_status's `ValueError`.
   - **upb's other rules.**
     - A string that is not UTF-8 gives `String field had bad UTF-8`.
     - A known field of another wire type is read as an unknown field.
     - A 10-byte varint and a field 0 inside a group are accepted; tags and 
lengths of more than 5 bytes are refused.
     - `Any.Is` and the map entries of an `ErrorInfo` follow upb too.
   - **The point and chain of the error.**
     - After the `GRPC Error received` log, the error has grpcio's error as its 
context.
     - Inside a policy's `can_retry`, it has that context and no log.
     - Between retries, it has no context.
     - For executions, it has `_operation_id`.
     - Between retries, the `DefaultPolicy`'s read of the status raises 
PySpark's class, with the `KeyError` context of "Invalid status code".
   - **The reader.** It is a new reader of the `google.rpc` details, 
`crates/spark-connect-core/src/rpc_status.rs`, which skips groups without 
recursion.
   - **The Rust API is unchanged:** it decodes the details with prost and never 
raises a `DecodeError`. Only the text of the hidden `Received ErrorInfo` log 
changes; it uses the depth-guarded decode.
   - **The KD row.** "A `grpc-status-details-bin` that does not decode" is 
reduced to what remains. Under protobuf's pure-Python implementation 
(`PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python`), PySpark parses with 
protobuf's Python decoder, of its own rules and errors, while the drop-in keeps 
upb's, as its protobuf runtime always does.
   - **The docs.** The compat paragraphs on the `-bin` metadata and status 
details are rewritten to what is true:
     - a `-bin` value that gRPC core cannot decode fails the call `INTERNAL` 
with empty details, whatever the server's code;
     - no padding and a trailing `=` are accepted, and `YW==` is refused.
   
   ### Why are the changes needed?
   
   To close the KD row's difference from PySpark: the errors of the status 
details that PySpark's client raises with upb.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, the errors above, of malformed status details that only a broken server 
sends.
   
   ### How was this patch tested?
   
   - New tests in `python/tests/test_dropin_offline.py` against a raw HTTP/2 
server. Two of them fail without the change; the third guards the re-check of 
the oversize limit. There are also core unit tests (`rpc_status`, `error`, 
`retries`).
   - Probes of both clients against the raw HTTP/2 server: 62 cases, each 
through `conf.get` and `collect`. 88 of the 124 calls differed from PySpark 
before the change, and none after.
   - A differential fuzz of the reader against upb: 150,000 random and mutated 
`Status`, `ErrorInfo` and `RetryInfo` encodings, and 20 cases at the 65535 
limit, with no mismatch.
   - The core tests (release and debug), the native server's crates, clippy, 
rustdoc, the stubs, the tooling tests, the offline suite under coverage, and 
the e2e with and without protobuf.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code
   
   This pull request and its description were written by Isaac.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to