HyukjinKwon opened a new pull request, #479: URL: https://github.com/apache/spark-connect-rust/pull/479
### What changes were proposed in this pull request? [SPARK-61389](https://issues.apache.org/jira/browse/SPARK-61389): a follow-up of #439 (SPARK-61319) and #469 (SPARK-61362), from a review of #439. The port of a Spark Connect connection string is now read as `urllib.parse`'s `port` reads it, ASCII digits only within 0-65535 (`channel.rs`, new `parse_port`): - An out-of-range port, including an overflowing run of digits, gives `Port out of range 0-65535`. - Any other port gives `Port could not be cast to integer value as '<value>'`, with the value repr-quoted and no URL. The token redaction of #439 is unchanged. - An empty port is still the default, and `0080` is 80. The errors that PySpark raises as the builtin `ValueError`, the port errors and the keepalive `int()` error of #469, now have a `SparkErrorKind::BuiltinValueError`. The Python drop-in raises them as the builtin `ValueError`, not `PySparkValueError`, as the `RecursionError` and `UnicodeDecodeError` kinds do. ### Why are the changes needed? Before, `SparkSession.builder.remote("sc://localhost:99999/;token=SECRET").create()` raised `PySparkValueError: Port could not be cast to integer value as '99999'`. PySpark 4.3.0 raises `ValueError: Port out of range 0-65535`. A port with a leading `+` (`sc://localhost:+80/`) was accepted, because Rust's integer parser allows a sign; urllib rejects it. Checked against the reference with `99999`, `65536`, `01234567890123456789`, `+80`, `notaport`, `abc`, `8 0`, `-1`, `1_0`, `%38%30`, `[::1]:x` and `[::1]:99999`. `create()` and `getOrCreate()` raise the builtin `ValueError` for all of them, and for the bad keepalive values. ### Does this PR introduce _any_ user-facing change? Yes, for bad connection strings only. The port error messages change as above, a port with a sign is rejected, and these errors and the keepalive one are the builtin `ValueError`. `PySparkValueError` is a subclass of `ValueError`, so `except ValueError` keeps working, but `type(e)` changes. ### How was this patch tested? - Rust unit tests in `channel.rs` for each port case, with the exact messages and kind. The keepalive kind assertions in `channel.rs` and `client.rs` are updated. - An offline Python test, `test_create_raises_for_a_port_that_urllib_rejects_as_pyspark`, that checks the exact type and message against PySpark 4.3.0's. - `cargo test -p apache-spark-connect -p apache-spark-connect-core --release --lib`, the `--no-run` builds, `cargo fmt --check`, and the offline and e2e drop-in suites against a Spark 4.3.0 server. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 5.5 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]
