Skip to content

fix: redact URLs in Parquet timestamp overflow errors and S3 setup logs - #7719

Open
sunchao wants to merge 9 commits into
apache:mainfrom
sunchao:fix/7128-native-scan-diagnostics
Open

sunchao wants to merge 9 commits into
apache:mainfrom
sunchao:fix/7128-native-scan-diagnostics

Conversation

@sunchao

@sunchao sunchao commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Which issue does this PR close?

Part of #7128. This covers two diagnostics alongside #7556, #7561, #7562 and #7565.

Rationale for this change

The native Parquet reader reports the failing file when a millisecond timestamp overflows during conversion to microseconds. The planner saves Spark's file URL for that error. S3 setup also logs the resolved Hadoop settings, including the endpoint. Either URL can carry credentials.

The scan change is specific to ParquetTimestampOverflow. The separate JVM CannotReadFile fallback builds a list from taskFilePaths and is outside this PR. SparkErrorConverter

What changes are included in this PR?

  • Keep Spark's spelling for ordinary file paths, including escaped filename delimiters. Strip actual query and fragment components. When userinfo needs removal, use the shared URL helpers on the reader's normalized URL and restore Spark's scheme. This preserves the Azure container and handles S3 aliases whose bucket comes from the path.
  • Keep the region, addressing mode, requester-pays flag and sanitized endpoint in the S3 debug output. Hide the endpoint if it cannot be parsed or could contain userinfo in its path. The S3 builder uses the original settings.

How are these changes tested?

A planner regression checks the per-file path saved for the overflow error. It covers encoded filename characters, Azure containers and S3 alias normalization, including a discarded bucket segment. Existing Spark scan tests exercise overflow reporting across files and batches.

An S3 regression checks the logged settings for a per-bucket endpoint, verifies that the builder retains the original value and covers malformed endpoints. Hosted CI runs the tests.

@github-actions github-actions Bot added bug Something isn't working area:scan Parquet scan / data reading labels Nov 20, 2026

@andygrove andygrove left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR backlog is huge and the maintainers don't have the bandwidth to review them all, so here is an automated review. Feel free to ignore it.

I built the native crate at the current head and ran the two new tests, and both pass. I also fed extra inputs through SparkFilePath::new and the output was credential-free for all of the realistic ones: an encoded / in a password, an empty username with a password, hdfs with a password and a query, abfss with a container and a password, https userinfo, and the explicit-authority and opaque s3a forms. Paths with no credentials come back as Spark spelled them, so the error text for ordinary paths does not change.

One input still leaks. In SparkFilePath::new, the early return trusts url.username() and url.password() on the normalized URL. For a hostless alias with a dot segment after the first segment, such as s3a:///u:p@bucket/../x/y or s3a:///u:p@bucket/%2e%2e/x, Url collapses the path to /x/y, rewrite_alias_to_s3 promotes x to the bucket, and the normalized URL carries no userinfo. The function then returns the raw path, and the diagnostic reads s3a:///u:p@bucket/../x/y. Spark would not normally hand the native side a hostless URL with userinfo and dot segments, so this is far from the common case. Since the PR is meant as defense in depth, could the early return also require that the raw path has no @ in its first authority-or-segment position, rather than relying only on the parsed userinfo? Alternatively, could the authority_matches check run before the early return, so both paths go through the same rule? A table row for this input would pin it.

@andygrove andygrove left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an automated re-review of the changes pushed since my earlier automated review. Feel free to ignore it.

The earlier ask is addressed. SparkFilePath::new no longer trusts the parsed userinfo for a hostless s3a alias, and hostless_alias strips userinfo from every segment that can still become the bucket, including ones a later .. or %2e%2e discards. I ran the new head on s3a:///u:p@bucket/../x/y, s3a:///u:p@bucket/%2e%2e/x, the one-slash and four-slash spellings, mixed-case dot segments, and a drive-letter segment, and none of them show the password. A randomized check of about 600,000 hostless paths built from dot segments, empty segments, drive letters, and one credential-bearing segment found no case where that segment was printed while it could still become the bucket. I found nothing else in the delta to raise.

@sunchao

sunchao commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

cc @andygrove @comphead @viirya

@comphead comphead left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the redaction paths at the PR head and found no remaining credential leak in the scan error or the S3 setup log. The planner is the only place that builds the diagnostic path, s3.rs now logs only config keys, and the other URL-bearing messages already go through url_redaction.rs from #7127. My one concern is that this PR adds a second, hand-written redaction implementation instead of using that one.

@comphead comphead left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @sunchao, the PR goes into right direction, please check some nits!

@viirya viirya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sunchao. I found no remaining leak in the new code.

One gap outside the diff: the CannotReadFile fallback in SparkErrorConverter fills filePath from taskFilePaths, which CometNativeScanExec builds from _.filePath.toString without redaction. That puts every file of the task, unredacted, into the same FAILED_READ_FILE error. Could the description scope the claim to the overflow path, or should that fallback get the same treatment?

@sunchao sunchao changed the title fix: keep URL credentials out of Parquet scan errors and S3 setup logs fix: redact URLs in Parquet timestamp overflow errors and S3 setup logs Dec 4, 2026

@viirya viirya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sunchao, LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:scan Parquet scan / data reading bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants