fix: parse_url handles relative references like java.net.URI #7392
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.48) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 545 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.377
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #7392"
general
weight: 0.35
comphead
Which issue does this PR close?
Closes #7385.
Rationale for this change
Native
parse_url/try_parse_urlreturn NULL for every part of a URL without a scheme (/p?id=1,?id=7,//host/p,notaurl). Spark'sParseUrlusesjava.net.URI, which parses these as relative references, so with Comet enabledparse_url(page, 'QUERY', 'gclid')on logged page paths silently returns NULL instead of the value.What changes are included in this PR?
In
parse_url_component, the earlyreturn Ok(None)for scheme-less values is replaced by the two cases wherejava.net.URIactually rejects such a value::(empty scheme name, "Expected scheme name at index 0") →INVALID_URL;//,http://, "Expected authority") →INVALID_URL.Everything else goes through the existing
decompose_uri/ part extraction, which already splits relative references per RFC 3986 Appendix B.Side effects, both matching Spark:
://inside a relative URL's query (/r?to=http://x.com&id=1) no longer raisesINVALID_URL.http://(scheme, empty authority, nothing else) used to return PROTOCOLhttp; it now raisesINVALID_URL(ANSI) / returns NULL, as Spark does.Not in scope: Comet's character validation (
has_invalid_uri_chars) is narrower thanjava.net.URI's (e.g.|, a malformed%escape, a second#), andextract_hostdoesn't model registry-based authorities (//ex_ample.com/p). Those gaps already exist for absolute URLs and are tracked in #7330; with this change scheme-less inputs reach them too (Spark returns NULL for such inputs, Comet now returns parsed values instead of NULL).How are these changes tested?
parse_url.sql, plus relative and error cases inparse_url_ansi.sql.CometSqlFileTestSuite parse_urlpasses locally (Spark 4.1 profile) and fails onmainat the new queries.parse_url.rsfor the changed branch:test_relative_reference(a few relative references per part, expectations from Spark 4.1.1) andtest_invalid_relative_reference(:,:foo,://missing-scheme,//,http://). Both fail onmain; all existingspark-exprtests pass,cargo fmtandclippy -D warningsare clean.try_parse_url+java.net.URIvalidity on ~110k generated URLs and ~40k real-world relative page paths (each also tried with a host prepended): no change in results for absolute URLs except thehttp://-style inputs above; relative references now match Spark except the inputs covered by #7330.cargo bench --bench parse_url(main vs this branch): existing absolute-URL cases unchanged (all within ±4%). Scheme-less rows now do the normal extraction instead of returning early.🤖 Generated with Claude Code
UPD: after review
java.net.URIfor relative and absolute URLs:",\,^, ``,|, DEL and non-ASCII control or space characters, a%not followed by two hex digits,[or]in a hierarchical path, and a second#giveINVALID_URL(ANSI) or NULL. This covers the character rows of #7330, so the "Not in scope" paragraph above no longer applies to them.,1http://…are invalid), and a scheme with nothing after the:(http:,http:#f) is invalid.,urn:isbn:123,http:p?id=1) return only PROTOCOL and REF, as Spark does.(//ex_ample.com/p, the host rows of #7330).andtest_parse_url_schemestables inparse_url.sqland error cases inparse_url_ansi.sql.test_relative_referenceandtest_invalid_relative_referencewere replaced bytest_invisible_chars`, since the SQL files cover the rest. The differential run was repeated. All ~40k real relative paths, with and without a host prepended, match Spark 4.1.1. On the ~110k generated URLs, no row that matched before stops matching, and matching rows go from 61k to 96k. The remaining differences are in the authority, which is #7330.