[SPARK-58946][SQL] Reject invalid CSV file extensions - #58226
Conversation
…ree letters Signed-off-by: subhramit <subhramit.bb@live.in>
|
Just to highlight - cc @uros-b @gengliangwang |
| } | ||
|
|
||
| test("SPARK-58946: reject file extensions that are not exactly three letters") { | ||
| Seq("abcd", "ab1", "a").foreach { ext => |
There was a problem hiding this comment.
The test checks "abcd", "ab1", and "a" but omits "a/b", the path-separator case that the PR description explicitly singles out as a security concern (it would place a directory separator inside a filename component). Since the PR description treats this as a distinct risk, a test case for it would concretely validate the fix for that input and is worth adding alongside the others.
There was a problem hiding this comment.
Since the test checks "reject file extensions that are not exactly three letters", I'll add a separate one below with the path separator case.
Signed-off-by: Subhramit Basu <subhramit.bb@live.in>
Signed-off-by: Subhramit Basu <subhramit.bb@live.in>
Follow-up to #58225
Closes SPARK-58946
What changes were proposed in this pull request?
Changes
&&to||in theextensionoption validation inCSVOptions.scala:127.Depends on SPARK-58945. Until that merges this path surfaces
INTERNAL_ERRORrather than the intended error, so the new test will not pass on its own.Why are the changes needed?
The error message states the extension is limited to exactly three letters, which requires rejecting anything not both three characters and all letters.
&&rejects only values failing both clauses, so these are accepted today:abcdab1aa/bThe value flows into the output filename (
CSVWrite.scala:61,CSVFileFormat.scala:91), soa/bplaces a path separator inside a filename component.Does this PR introduce any user-facing change?
Yes. Writes that previously succeeded with an out-of-contract extension now fail with
INVALID_PARAMETER_VALUE.EXTENSION. The option was documented as three letters only, so affected jobs were relying on validation that did not match its stated contract. Valid three-letter extensions are unaffected, and the only extension used in existing tests (tsv) remains valid.How was this patch tested?
New case in
CSVSuitecoveringabcd,ab1, anda. The existingSPARK-50616tsv test continues to pass.TODO: full suites:
should pass once #58225 is merged and synced here.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5