Skip to content

fix: keep URL passwords and query strings out of Iceberg plan strings and fallback reasons - #7743

Draft
dwsmith1983 wants to merge 38 commits into
apache:mainfrom
dwsmith1983:fix/7734-iceberg-write-plan-location
Draft

dwsmith1983 wants to merge 38 commits into
apache:mainfrom
dwsmith1983:fix/7734-iceberg-write-plan-location

Conversation

@dwsmith1983

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #7734.

This builds on NativeConfig.displayPath from #7565, so it merges after #7565. Its own change is the last commit on the branch.

Rationale for this change

The Iceberg write and scan plan strings printed the table's data and metadata locations as given, and so did several Iceberg fallback reasons. A location with a password in its userinfo or a signed query string then showed up in explain(), the SQL UI node description, the event log and the fallback report. A location that java.net.URI rejects was worse: the URISyntaxException message, which quotes the whole input, became the fallback reason.

What changes are included in this PR?

  • NativeConfig.displayLocation(String) shows a location string through displayPath. A location URI cannot parse shows only its scheme, or <unparseable>.
  • The CometIcebergWrite and CometIcebergNativeScan plan strings use it for the data and metadata locations.
  • Write fallback reasons use it: no bucket in the authority, and the two gs:// FileIO reasons.
  • A data location URI cannot parse now falls back with <scheme> data location is not a valid URI for every write scheme. It already fell back before, through an exception that quoted the location.
  • Scan fallback reasons use it too: an Iceberg metadata location URI cannot parse, and a file location without a URL host.
  • iceberg.md lists the new write fallback, and iceberg-writes.md says the plan string hides the location's password, query and fragment.

No query changes between native and Spark execution, only the text that names the location. Logs and exceptions that still print a location are tracked in #7737.

How are these changes tested?

NativeConfigSuite covers displayLocation for userinfo, queries and fragments, an ABFS container, passwords that end the authority early, strings URI rejects, and locations shown as given. CometIcebergWriteDetectionSuite checks both plan strings and the write fallback reasons on real and hand-built plans, including s3, gs, file and plain locations that URI rejects. CometIcebergNativeSuite checks the two scan fallback reasons on real tables. Each test fails on the base branch, and reverting any one changed site fails a named test.

… logs

The native Azure store printed whole URLs in its errors and debug lines,
and handed them to object_store, whose own errors quote the URL. A
password in the userinfo or a SAS token in the query could end up in
task errors and logs.

object_store now gets a copy without the password, query and fragment,
keeping the container it reads from the username. Messages name the URL
by scheme, container and host only.
… driver messages

object_store_authority kept an ABFS URL's password, so it reached the
store cache key, the registration URL, debug lines and the
deregister_store error. object_store_backend parsed the raw URL and
normalize_object_store_url echoed input it could not parse. On the
driver, AbfsAuthResolver put the URI into forwarded errors and a
warning, and the mixed-store decline reason and objectStoreKey kept the
raw authority.

All of these now name a URL by scheme, container and host only. The URL
helpers move to objectstore/url_redaction.rs, NativeConfig gains a
matching displayAuthority, objectStoreKey matches the native key again,
and the resolver scrubs the URI's password and query from Hadoop
messages it forwards. Credentials only come from configuration, so URLs
that differ only by password share a store.
The message no longer needs the host, so the redacted helper that
built it is removed.
Drop comments that restate the code or a test's name, and shorten the
rest to why each part of a URL is kept or removed.
Native now builds the key callback path from the authority without its
password, so the retriever registered under the listed path was never
found. Register and look up retrievers by one key: S3 aliases folded to
s3a, and for abfs/abfss the scheme lowercased and the password dropped
by the same rule as native. The missing-retriever error prints that key.
Secrets were replaced one after another, so a URI password inside a
configured credential was masked first and the rest of the credential
stayed in the message. Match every secret in the same text and replace
each run of masked characters with one marker.
The object store key is built per file during fallback checks and again
per split in partition packing. Return the raw authority as is when it
has no `@`, or no `:` before the last `@`, instead of rebuilding the
same string.
…layAuthority

nativeFallbackReason stripped the URL password with its own copy of the
logic in NativeConfig.authorityWithoutPassword. Use the shared helpers so
the resolver renders a location one way in every message: lower-case
scheme, no password, path or query.
The ABFS resolver skipped secrets under eight characters, so a short
password in the URI reached the driver warning when Hadoop named the
container-scoped keystore alias it could not recover. URI secrets are
now hidden at any length; the floor applies only to configured values.

The password is read from the raw authority, split as Hadoop splits the
container, so a registry-based authority (an underscore in the host)
no longer loses it.
When object_store cannot open a path, the scan falls back to Spark with
a reason that names the path. The native Parquet scan printed the whole
URI there, and the native Delta scan masked the user info but kept the
query, so a password, a SAS token or a signature reached the plan and
the fallback report.

NativeConfig.displayPath shows a URI without its password, query or
fragment and masks the username as ***, keeping an ABFS username, which
names the container. It reads the user info from the raw authority, so
registry based hosts are covered. A URI with nothing to hide reads as
before, and an opaque one shows only its scheme. Both reasons use it.
dwsmith1983 and others added 8 commits November 9, 2026 09:07
…h-reason

# Conflicts:
#	spark/src/main/scala/org/apache/comet/objectstore/NativeConfig.scala
#	spark/src/test/scala/org/apache/comet/objectstore/NativeConfigSuite.scala
…h-reason

# Conflicts:
#	spark/src/main/scala/org/apache/comet/rules/CometScanRule.scala
A password containing `/`, `?` or `#` ends the URI authority before its
`@`, so displayPath saw no user info and printed the rest: for
`s3a://alice:/SECRET@bucket/p` the whole string, for
`s3a://alice:?SECRET@bucket/p` the username. An `@` after the authority
now shows only the scheme, as the native redaction does. A real `@` in a
path looks the same and is hidden too.
… and fallback reasons

The Iceberg write and scan plan strings printed the data and metadata
locations as given, as did several Iceberg fallback reasons, so a password
or signed query ended up in explain(), the SQL UI, the event log and the
fallback report. A location java.net.URI rejected was worse: the
URISyntaxException message, which quotes the input, became the reason.

NativeConfig.displayLocation shows a location string through displayPath,
or only its scheme when URI cannot parse it. Both plan strings and the
location-naming write and scan fallback reasons use it, and a data
location URI cannot parse now falls back with a named reason for every
write scheme instead of through the exception.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CometIcebergWriteExec prints the Iceberg data location with its credentials in the plan

1 participant