Area: Ingestion Issues
Sub-Area: S3 URN Encoding / Lineage Helper Functions
Applies to: OSS + Cloud
Issue
Older CLI versions built S3 dataset URNs for lineage without encoding the characters that URNs reserve. When an S3 path contains (, ) or , (for example s3://my-bucket/data/folder(1)/file.parquet), the connector produces an invalid URN. You see this error:
InvalidUrnError: DatasetUrn name contains reserved characters
This affects S3 URNs that the Snowflake, Glue, Athena, SageMaker and Unity Catalog connectors build, and Azure Blob Storage URNs for Snowflake external stages. With an affected CLI:
- A Snowflake run fails and loses all of its lineage.
- Athena runs on non-Glue catalogs report a lineage failure.
- S3 datasets that Glue creates with
glue_storage_lineage_direction: downstreamare rejected by a server with strict URN validation.
The S3 source itself already encoded these characters, so it is not affected.
You Might Be Asking
- Why does Snowflake (or Glue, Athena, SageMaker, Unity Catalog) lineage fail only for certain S3 paths?
- Is there a fix, or do I need a workaround?
- Will the fix create duplicate S3 datasets or lineage edges?
- How do I build a valid S3 dataset URN in my own SDK code?
Cause
URNs reserve ,, (, ) and ␟. Inside a URN, these characters must be percent-encoded: ( becomes %28, ) becomes %29, and , becomes %2C. See URN restrictions.
In older CLI versions, the make_s3_urn and make_s3_urn_for_lineage helpers put the raw S3 path straight into the URN string. The connectors listed above call these helpers. Any path with a reserved character produced a URN that fails to parse.
The current helpers pass the path through the SDK's URN encoder, so folder(1) becomes folder%281%29. Only ,, (, ) and ␟ are encoded. Slashes, % and all other characters stay as they are. Paths without reserved characters produce the same URN as before.
Solution
There is no recipe setting that changes how these connectors build S3 URNs. Upgrade the CLI that runs the ingestion.
-
Upgrade to the latest
acryl-datahubrelease. Release 1.7.0.20 includes the fix.pip install --upgrade acryl-datahub- For UI ingestion, open the ingestion source, go to Advanced Settings, and set CLI Version to the latest release.
- DataHub Cloud v2.4.0 and later include the fix (see the v2.4.0 release notes). If you use a Remote Executor, run an image from v2.4.0-cloud or later.
- DataHub OSS v1.9.0 includes the fix. It is listed under v1.9.0 in Breaking Changes by Version.
-
Check that your installed CLI encodes the path. This only builds a URN string and writes nothing to DataHub:
from datahub.ingestion.source.aws.s3_util import make_s3_urn_for_lineage from datahub.metadata.urns import DatasetUrn urn = make_s3_urn_for_lineage("s3://my-bucket/data/folder(1)/file.parquet", "PROD") print(urn) # urn:li:dataset:(urn:li:dataPlatform:s3,my-bucket/data/folder%281%29/file.parquet,PROD) DatasetUrn.from_string(urn)If
DatasetUrn.from_stringraisesInvalidUrnError: DatasetUrn name contains reserved characters, your CLI does not have the fix yet. -
Re-run the ingestion.
-
Clean up old URNs if needed. Most deployments need no action. Two cases do:
- With
incremental_lineage: true, the old lineage edge to the unencoded URN stays next to the new one. Remove the old edge. - S3 datasets that Glue created with
glue_storage_lineage_direction: downstreamget a new encoded URN. With stateful ingestion, the next run soft-deletes the old dataset. With stateful ingestion off, the old dataset stays as a duplicate. Descriptions, tags or owners you added in the UI stay on the old dataset, so add them again to the new one.
- With
Building S3 URNs in your own SDK code
The upgrade does not change code you wrote yourself. If your code builds S3 dataset URNs with an f-string, build them through DatasetUrn instead. Its constructor encodes the reserved characters for you:
from datahub.ingestion.source.aws.s3_util import strip_s3_prefix
from datahub.metadata.urns import DatasetUrn
urn = DatasetUrn(
platform="s3",
name=strip_s3_prefix("s3://my-bucket/data/folder(1)/file.parquet"),
env="PROD",
).urn()
print(urn)
# urn:li:dataset:(urn:li:dataPlatform:s3,my-bucket/data/folder%281%29/file.parquet,PROD)
This matches what make_s3_urn_for_lineage returns for the same path, as long as the path has no trailing slash. make_s3_urn (used by Glue, Athena and SageMaker for their S3 datasets) differs: by default it also replaces the file extension dot with an underscore (file.parquet becomes file_parquet) and drops a trailing slash. To match those URNs, call make_s3_urn from an upgraded SDK.
A path that you already encoded by hand is not encoded twice. The encoder leaves % alone, so %28 stays %28.
Related Documentation
- URN restrictions
- Breaking Changes by Version (v1.9.0, "Ingestion / S3 lineage")
- DataHub Cloud v2.4.0 release notes
- Snowflake source
- Glue source
- Athena source