Skip to content

[Server] Validate storage locations against their column and cloud limits - #2378

Open
maharanay22 wants to merge 29 commits into
unitycatalog:mainfrom
maharanay22:validate-storage-locations
Open

maharanay22 wants to merge 29 commits into
unitycatalog:mainfrom
maharanay22:validate-storage-locations

Conversation

@maharanay22

@maharanay22 maharanay22 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

This was split out of #2234, which widened the storage path columns and is now merged.

Validating locations

#2234 widens the storage path columns. A location that fits its column can still be unusable, because the server builds managed locations under a root, and because the clouds have their own limits for object names and for the credentials the server vends. StorageLocationValidator now checks every location the server accepts or derives, before anything is stored, and rejects it with INVALID_ARGUMENT:

  • catalog and schema storage roots, through validateCatalogStorageRoot and validateSchemaStorageRoot, against every kind of managed location the server creates under them: tables (and staging tables), volumes, registered models and model versions
  • external volume locations, external table locations, and external location URLs when they are created or changed
  • the derived locations of new managed staging tables, volumes, registered models (with the model versions under them) and model versions, which also covers locations under the storage-root.tables and storage-root.models fallbacks
  • model version source, which is only length checked

A location given in a request is checked against its column in characters, counted the way the configured database counts them, so a non-ASCII path that fits today keeps working. H2 counts UTF-16 code units and PostgreSQL and MySQL count code points, so an emoji is two characters on H2 and one on the others. The validator takes this from the Hibernate dialect. A root and the managed locations under it are checked in UTF-8 bytes, which is stricter and keeps the indexed uc_staging_tables.staging_location within PostgreSQL's 2,704 byte index entry limit. For a root the error says how long it can be: Storage root is 1943 bytes long in UTF-8, but it can be at most 1942 bytes so that managed table and volume locations under it fit in 2048 bytes. For an ASCII root that is 1,942 characters for a catalog and 1,943 for a schema. The column widths are constants in Constants that the DAOs and the validator share.

The cloud limits come from CloudCredentialVendor.limitViolation, which each vendor implements with the same code it uses to vend, without calling the cloud. A managed location has to leave room for an object under it, since the server writes there. So does a location given in a request that holds files: an external location, an external volume, and an external Delta or Iceberg table. An external Delta table leaves room for its first commit, _delta_log/00000000000000000000.json (37 characters and two path segments more), which every Delta table has, so no location of an existing table is rejected for it. A managed Delta table, and a staging table, use V2 checkpoints, so they leave room for the longest file name they need, the temporary file a V2 checkpoint sidecar is written to before it is renamed on Azure: _delta_log/_sidecars/.<version>.checkpoint.<part>.<parts>.<uuid>.parquet.<uuid>.tmp, 162 characters and three path segments more (delta-spark FileNames.newV2CheckpointSidecarFile and Checkpoints). An Iceberg table, and a staging table created through the Iceberg REST catalog, leave room for a manifest list, metadata/snap-<snapshot id>-<attempt>-<uuid>.avro, which is 78 characters with a 19 digit snapshot id and two path segments more (Iceberg 1.11 SnapshotProducer.manifestListPath). That is longer than the metadata file the server writes. Main accepted Iceberg locations within 78 characters of the object name limit, or within two segments of Azure's 254, and these are now rejected. Only an external table in a format that may be a single file, such as CSV, may name a single object, so it only has to be a valid object name itself. Each caller passes this extent. StorageLocationValidator is in persist.utils, next to the repositories that call it in their transactions. Each limit is checked only where it is certain to apply:

  • AWS S3, when the location's credential is an aws_iam_role or its bucket is configured in the server without a custom generator: object keys are at most 1,024 bytes (S3 object keys), and when the vend assumes a role, the session policy AwsPolicyGenerator builds is at most 2,048 characters. Managed locations, which the server writes to, are checked with the SELECT and UPDATE policy. Locations given in a request, which may only be read, are checked with the SELECT policy, and a write vend whose policy doesn't fit fails at vend time (AssumeRole). So a long S3 external location, table or volume can be accepted and read but not written. Checking these with the write policy would reject long locations that are only read, which work on main today. The docs say this. The policy repeats the path five times, so this is the limit that binds first, below the 255 characters main allows for a root. A vend whose policy is too long now fails with INVALID_ARGUMENT before calling STS, instead of a 500 from STS.
  • GCS: object names are at most 1,024 bytes (objects), and for a configured bucket without a custom generator, where the vend builds a credential access boundary, its condition is at most 2,048 characters (AccessBoundary).
  • Azure: blob names are at most 1,024 characters with at most 254 path segments (blob naming). A hierarchical namespace account allows only 63 segments, counting the account and container. Nothing the server is given says whether an account has one, so that limit isn't checked. The new Storage location limits section in docs/server/configuration.md says so, along with how many segments managed locations add. Azure SAS tokens have no length limit.
  • S3-compatible storage is not checked. Its limits differ between stores (MinIO allows 1,024 or 4,096 byte names depending on mode) and its STS publishes no policy limit.

A location whose covering external location's credential was force-deleted is only length checked, with a warning in the log, and its vend reports the missing credential as before. The lookup returns that case as a value (CoveringCredential.Deleted), so any other lookup error, such as two external locations covering one path, is reported and not skipped. One method decides the credential for both a looked-up location and an external location URL, and CloudCredentialVendor.limitsDependOnCredential says for each scheme whether its limit checks read the credential (S3 and GCS do, Azure doesn't). The same holds for an external location URL change after its credential was force-deleted. The S3 or GCS URL is checked only against the column, and not against the server's bucket configuration, which the vend would not use. The credential is looked up only for S3 and GCS, the vendors whose checks depend on it. A root without a bucket, such as s3:/// or gs:///, normalizes to a URL that doesn't parse, so the credential lookup failed with a 500. It is now rejected with INVALID_ARGUMENT, and so is an opaque cloud URI without a bucket or container, such as s3:a/b. Locations already stored are not checked again. A credential-only update of an external location checks only the AWS STS session policy of the new credential, since that is the only limit that depends on it. So a location stored before these checks, such as one without a bucket, can still rotate its credential, while a URL whose policy can't fit the new credential is still rejected.

The API spec says the same for API callers, as asked in the #2234 review. The path fields of the create requests for catalogs, schemas, volumes, tables and model versions, and the URL of the external location create and update requests, now say how long they can be. The catalog and schema storage_root descriptions also say that the managed location under the root has to fit, so a catalog root can be at most 1,942 bytes in UTF-8 and a schema root at most 1,943. The reference pages in api/Models are regenerated.

Testing

StorageLocationValidatorTest checks the validator against the real vend path. For an S3 bucket with an STS role, and for an aws_iam_role credential, it goes through every root path length from 1 to 600 for catalog and schema roots and asserts that a root is accepted exactly when CloudCredentialVendor.vendCredential with SELECT and UPDATE succeeds for the managed table, volume, registered model and model version under it, with a mocked STS client. It asserts the accepted lengths have no gaps, the boundary is inside the range, and the longest policy sent to STS is within five characters of 2,048. Other tests cover:

  • a too-long policy failing before STS is called
  • a request location accepted exactly when a read vend succeeds, and a managed location exactly when a read/write vend succeeds, with lengths in between where only reads fit
  • a single-file request location naming one object, a 1,024 byte S3 key and an Azure blob of 1,024 characters and 254 segments, accepted while the same location as a directory, a managed location or an external location URL is rejected, and a directory at 1,022 characters or 253 segments accepted
  • external Delta tables reserving their first commit, Iceberg tables treated as directories, and other formats as possible single files, for every table format
  • S3-compatible storage limited only by the column, and a static key S3 bucket limited by the object key length at exactly 1,024 bytes
  • GCS object names counted in bytes with a three-byte character, and the GCS condition checked for a configured bucket but not for one with a custom generator or an unconfigured one
  • Azure names counted in characters (with é) up to exactly 1,024 and path segments up to exactly 254
  • a registered model rejected when its model versions can't fit, at the exact boundary
  • a force-deleted credential leaving the cloud checks to the vend, and any other lookup error reported
  • an external Delta table location accepted exactly when its first commit's object key is 1,024 bytes and its Azure blob name 254 segments, and a managed one exactly when its temporary checkpoint sidecar's is, for request and managed locations
  • s3:a/b, gs:a/b and abfss:a/b roots rejected with INVALID_ARGUMENT
  • an external location URL with a force-deleted credential checked only against the column on a bucket the server has a role for, while the same URL with an aws_iam_role credential is rejected for its session policy
  • a request location counted in code points or in UTF-16 code units, with emoji
  • a request location counted in characters (2,048 é characters pass) and a managed location in bytes, and the exact column limits for catalog and schema roots including a two-byte root

GcpCredentialVendorTest.testGcsStorageRootIsAcceptedExactlyWhenManagedCredentialsCanBeVended does the same for GCS against downscopeGcpCreds, over root lengths 1 to 500, two bucket name lengths (one makes a condition of exactly 2,048 reachable) and path characters that CEL escapes (" and \), and asserts the longest condition vended is within eight characters of 2,048.

Mutations that each of these catch include dropping UPDATE from the checked privileges, leaving out the model version location, not looking up the root's credential, failing on an unresolvable credential, not treating a static key bucket as AWS S3, counting characters where bytes are needed or the reverse, skipping the GCS name check, checking the GCS condition for every bucket, an off by one in object names or segments, removing the vend time policy check, and an off by one in the column check.

SdkManagedLocationTest.testStoragePathsUpToTheColumnLimit checks over the API that a 1,943 character catalog root and a 1,944 character schema root are rejected, then creates the longest allowed roots. Under each it creates a managed volume of exactly 2,048 characters and a staging table of exactly 2,047, then an external volume of exactly 2,048 characters and a model version source of exactly 2,048, which are read back. One character more of either, and an external table location of 2,049 characters, are rejected with INVALID_ARGUMENT. BaseExternalLocationCRUDTest.testUrlUpToTheColumnLimit does the same for an external location URL at 255 and 256 characters, on create, on update and on an update that also changes the credential. testCredentialChangeChecksTheUrlAgainstTheNewCredential moves a URL from an S3-compatible credential to an aws_iam_role one whose session policy it doesn't fit, and the update is rejected. testUrlLengthIsCountedTheWayTheDatabaseCountsIt creates a URL of 255 code points with emoji, which H2 rejects with INVALID_ARGUMENT and PostgreSQL and MySQL store. SdkManagedLocationTest.testLocationsUnderAStoredLocationAreChecked stores a catalog location and a model URL too long for Azure, then checks that a managed volume, a staging table, a registered model and a model version under them are each rejected with INVALID_ARGUMENT. testDirectoryLocationsLeaveRoomForAFile creates an external volume and an external Iceberg table at a 1,022 character Azure blob name and rejects them at 1,023, creates an external Delta table at 934 and rejects it at 935, and creates a CSV table at 1,024 and rejects it at 1,025.testDirectoryLocationsLeaveRoomForAFile creates an external volume at a 1,022 character Azure blob name and rejects it at 1,023, creates an external Delta table at 987 and rejects it at 988, and creates a CSV table at 1,024 and rejects it at 1,025. The S3 and Azure root boundary tests find the longest accepted root where a managed table's temporary checkpoint sidecar is exactly 1,024 bytes or characters. testLocationsUnderAStoredLocationAreChecked expects the staging table's message to name the temporary checkpoint sidecar files.

A repository level run on H2, not kept as a test, shows the order before and after the check. Before, a 1,970 character catalog root is stored and the managed volume and staging table under it fail with Value too long for column "STORAGE_LOCATION CHARACTER VARYING(2048)" and "STAGING_LOCATION CHARACTER VARYING(2048)". After, it is rejected with Storage root is 1970 bytes long in UTF-8, but it can be at most 1942 bytes so that managed table and volume locations under it fit in 2048 bytes. A 1,942 character root is stored with its schema, managed volume and staging table, and a 1,943 character catalog root and a 1,944 character schema root are rejected.

BaseExternalLocationCRUDTest.testLocationsAreCheckedWithTheCredentialOfTheirExternalLocation creates an aws_iam_role credential and an external location on a bucket the server has no configuration for, so only the looked-up credential can limit it. A short volume under it is created, and a volume whose session policy is too long is rejected. With the credential still in place, the URL moves to another path under the same bucket, an update to a path whose session policy is too long is rejected, and the stored URL stays the moved one. After the credential is force-deleted, the URL moves to a bucket the server has its own role for with the same long path, which is accepted, and a 256 character URL is still rejected. SdkManagedLocationTest.testMalformedCloudStorageRootsAreRejected checks that s3:///, gs:///, s3://, gs://, s3:a/b and gs:a/b catalog and schema roots fail with INVALID_ARGUMENT, and that bucket roots are accepted.

StorageLocationValidatorTest.testTablesLeaveRoomForTheirLongestFile has an Iceberg row at the S3 key and Azure segment boundaries. RepositoriesTest.stagingTableLocationLeavesRoomForTheLongestFileOfItsTableFormat runs on H2 and checks that the same staging location passes for Iceberg at exactly 1,024 characters, fails for Iceberg at 1,025 and fails for Delta with the sidecar message, and IcebergRestCatalogServiceTest.managedCreateChecksTheStagingLocationForIcebergFiles checks that the Iceberg REST catalog passes the Iceberg extent. StorageLocationValidatorTest.testCredentialChangeChecksOnlyTheLimitsThatDependOnTheCredential and a server test of the same name check that a credential change accepts stored URLs over the column width, over the object name limit and without a bucket, and rejects one whose session policy can't fit, with the credential left unchanged. Reverting each of these changes makes one of them fail.

Locally on H2, 499 of 505 tests in StorageLocationValidatorTest, service.credential.*, RepositoriesTest, IcebergRestCatalogServiceTest, service.iceberg.*, service.delta.* and ExternalLocationUtilsTest pass. The other 6 are 3 MetadataServiceTest cases that fail on Windows on main too, and 3 ExternalLocationUtilsTest cases that fail locally with a missing shaded Hadoop class. javafmt and checkstyle pass for server. The Sdk, CLI and other server tests can't start on Windows, so they run on CI.

A catalog or schema storage root, a volume storage location or a model
version source longer than 255 characters failed with a 500, while table
locations allow 2048. Widen uc_catalogs.storage_root and
storage_location, uc_schemas.storage_root and storage_location,
uc_volumes.storage_location and uc_model_versions.source to
varchar(2048) with one step per column for H2, MySQL and PostgreSQL.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
…columns

Signed-off-by: Maha Rana Yadavalli <[email protected]>

# Conflicts:
#	server/src/main/resources/schema-effects/h2/V3.txt
#	server/src/main/resources/schema-effects/mysql/V3.txt
#	server/src/main/resources/schema-effects/postgresql/V3.txt
… steps don't break it

Signed-off-by: Maha Rana Yadavalli <[email protected]>
Main added step V4 (credentials stored as text), so this branch's steps move from V4..V9 to V5..V10 on H2, MySQL and PostgreSQL, with their effect files.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
Main added steps V5..V10 (unitycatalog#2187), so this branch's steps move from V5..V10 to V11..V16 on H2, MySQL and PostgreSQL, with their effect files.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
…rflow

A catalog or schema storage root can now be up to 2048 characters, but
managed volume, table and staging table locations append the managed
storage prefix and two ids to it. A 1970-character catalog root was
stored, and then creating a managed volume or staging table under it
failed at the database with a 2076 or 2075-character value.

Catalog and schema creation now reject a root whose longest managed
child location, a volume, would exceed 2048 characters, so the limit is
1942 characters for a catalog root and 1943 for a schema root. The
column length is shared through Constants.MAX_STORAGE_LOCATION_LENGTH.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
…icitly

Catalog and schema creation now call
ExternalLocationUtils.validateManagedLocationsFit next to the managed
prefix check, instead of the location builders validating as a side
effect. The longest managed location is counted in UTF-8 bytes, so a
root with multi-byte characters also keeps the indexed staging table
location within PostgreSQL's index entry limit. ASCII roots keep the
same 1942 and 1943 character limits. Model version source uses the
shared column length constant too.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
…entials

GcpCredentialVendor limits the access boundary condition to 2048
characters, and the condition repeats the object path four times. With
the wider columns a gs:// root of a few hundred characters was accepted
while credentials for managed tables and volumes under it could never be
vended. The root check now builds the same condition for those managed
locations and rejects the root if it is too long.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
…limits

The root check only covered the columns and the GCS condition of managed
tables and volumes. A new StorageLocationValidator now checks every
location the server accepts or derives: catalog and schema roots with all
managed locations under them (tables, volumes, registered models and model
versions), external volumes, external tables, external location URLs,
managed staging tables, volumes, models and versions, including those under
the server's storage-root fallback, and model version sources.

Each location must fit its column in UTF-8 bytes, and the cloud limits that
apply when it is used, computed the same way the credential vendors build
credentials, without calling the cloud:
- AWS S3 (an aws_iam_role credential, or a per-bucket config without an STS
  endpoint or custom generator): the 1,024 byte object key limit, and the
  2,048 character STS session policy limit for a vend that assumes a role.
- GCS: the 2,048 character access boundary condition.
- Azure: the 1,024 character blob name limit and 63 path segments.
S3-compatible storage is not checked, since its limits differ between
stores. A vend whose AWS session policy is too long now fails with
INVALID_ARGUMENT before calling STS, instead of a 500 from STS.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
- Locations given in a request (external tables, volumes and location
  URLs, model version sources) are checked in characters, as the columns
  count them, so non-ASCII paths that fit today keep working. Roots and
  the managed locations under them stay in UTF-8 bytes.
- The credential is looked up only for S3 and GCS, and a credential that
  can't be resolved, such as a force-deleted one, leaves the cloud checks
  to the vend instead of failing the create with a 500.
- GCS checks the 1,024 byte object name limit, which non-ASCII paths can
  reach before the condition limit, and checks the condition only for a
  configured bucket without a custom generator, where the vend builds one.
- Azure checks the 254 segment blob name limit, which holds for every
  account. The 63 segment limit of hierarchical namespace accounts can't
  be told from the URL.
- An external location URL is checked when it changes, not when only its
  credential changes.
- Column widths are constants used by both the DAOs and the validator.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
… call site

H2 counts a varchar's length in UTF-16 code units, PostgreSQL and MySQL in
code points, so the length check now follows the configured dialect. Log
when an unresolvable credential skips the cloud checks, and cover the update,
managed volume, staging table and model call sites.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
…tial changes

A location given in a request may only be read, so it only has to fit the
read-only STS policy. Write vends that don't fit still fail with
INVALID_ARGUMENT before STS. Managed locations keep the read/write check.
An external location's URL is now checked against a new credential even when
only the credential changes, unless it is a legacy URL that no longer parses.
The credential lookup result is a named type instead of a nested Optional.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
Pin that S3-compatible STS vends a policy over AWS's limit, that S3 buckets
with a custom generator or no configuration and GCS locations with a storage
credential aren't checked, and that a failing lookup leaves Azure's limits
checked. Drop the cloud storage root skip, since a root can't exceed a limit.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
…alidator to persist

A location given in a request, such as an external table that is one file,
only has to be a valid object name itself, so a 1,024 byte S3 key is no
longer rejected. Managed locations, which the server writes under, keep the
allowance for an object under them. The validator takes a Hibernate Session,
so it moves to persist.utils next to its callers.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
…paths as directories

A location that holds files has to leave room for one under it. Each caller now passes the
extent, so only a table in a format that may be a single file, such as CSV, keeps the
single-object check. Document the storage location limits, including the Azure hierarchical
namespace limit the server can't check.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
…tial was force-deleted, cover the credential lookup and malformed roots in server tests, and separate column widths from root and cloud limits in the docs

Signed-off-by: Maha Rana Yadavalli <[email protected]>
…rt credential lookup errors

A Delta table location now leaves room for its longest log file name,
_delta_log/_staged_commits/<version>.<uuid>.json. The credential lookup
returns a deleted credential as a value, so only that case skips the
cloud checks and an error such as overlapping external locations
propagates. One method decides the credential for both callers, and the
docs say request locations are checked with the read policy.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
…tial, and check both STS requests in the S3-compatible test

Signed-off-by: Maha Rana Yadavalli <[email protected]>
@yili-db

yili-db commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

/review

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

useful set of checks, though i left comments on two failing tests (Iceberg createTable and staging table message), checkpoint reserves, and opaque cloud URIs. i also asked about external Delta reserves and test coverage for URL updates with a live credential.

TestUtils.assertApiException(
() ->
createExternalTable(
EXTERNAL_TABLE_NAME, DataSourceFormat.ICEBERG, container + "t".repeat(1023)),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

to my understanding createExternalTable goes through the native createTable endpoint, which rejects DataSourceFormat.ICEBERG with UNSUPPORTED_TABLE_FORMAT before the location validator ever runs. so won't both this assertion and the success case right below fail, without actually covering Iceberg location validation? should we hit the Iceberg REST catalog endpoint here or test the Iceberg boundary directly in validator tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, fixed in f2af7af. The SDK test no longer creates an Iceberg table through the native endpoint. The validator tests cover the Iceberg extent and its boundary.

.schemaName(SCHEMA_NAME)
.name(TABLE_NAME)),
ErrorCode.INVALID_ARGUMENT,
rejection);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

staging tables use Extent.DELTA_TABLE, so the error message says the Azure blob names of its Delta staged commit files have instead of rejection. could we update this expectation (assuming we keep the staged commit reserve, or adjust if checkpoint reserve changes it)?

         ErrorCode.INVALID_ARGUMENT,
-        rejection);
+        "the Azure blob names of its Delta staged commit files have");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f2af7af. The staging table now expects the message about the temporary Delta checkpoint sidecar files, since managed tables use that reserve now.

*
* @see <a href="https://github.com/delta-io/delta/blob/master/PROTOCOL.md">Delta protocol</a>
*/
DELTA_TABLE(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

to my understanding managed Delta tables require V2 checkpoint support, whose sidecar files take 120 chars (and temp checkpoint files on Azure take 162), whereas this only reserves 90 chars for a staged commit. could a managed table pass validation here and still fail later when writing a required checkpoint? should we compute the reserve from the longest required file path instead, and update the boundary tests and docs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right. I checked FileNames.newV2CheckpointSidecarFile and the .tmp rename in Checkpoints. f2af7af makes managed and staging tables reserve that 162 character sidecar temp file, with boundary tests and docs updated.

private boolean limitsDependOnCredential(NormalizedURL location) {
URI uri;
try {
uri = location.toUri();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what happens for an opaque URI like s3:a/b or gs:a/b? toUri() succeeds for those, so there's no normal path or bucket and later code (or earlier Hadoop path handling) can throw and turn malformed input into HTTP 500 instead of 400. should we reject opaque cloud URIs and missing bucket/container authorities during URL normalization and add catalog/schema tests for s3:a/b and gs:a/b?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f2af7af. An s3, gs or abfs URI that is opaque or has no bucket or container is now rejected with INVALID_ARGUMENT. Unit tests and testMalformedCloudStorageRootsAreRejected cover s3:a/b and gs:a/b.

session,
storageLocation,
Constants.MAX_STORAGE_LOCATION_LENGTH,
StorageLimits.Extent.ofTable(createTable.getDataSourceFormat()));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is in the external table branch, where ofTable(DELTA) reserves space for staged commits even though the server's Delta commit path only accepts managed tables. does that mean we'd now reject existing valid external Delta locations based on an operation they can't use? should we pass Extent.PREFIX here instead and add a regression test for it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed that staged commits don't apply here. In f2af7af external Delta tables reserve only the first commit, _delta_log/00000000000000000000.json. Every Delta table has that file, so no existing location is rejected for it.

// Checked whether or not the URL changes, against the credential's committed type.
validateUrlForCredential(existingLocation.getUrl(), current);
if (updateExternalLocation.getUrl() != null) {
validateUrlLimits(existingLocation.getUrl(), Optional.ofNullable(current));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

to my understanding the cloud-limit URL update tests only run after the credential was deleted, so this path with a live credential isn't exercised. could we test both an allowed URL update and a policy-expanding URL rejection before deleting the credential, and verify the stored URL stays unchanged?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in f2af7af. Before the credential is deleted, the test moves the URL, rejects a policy-expanding update, and checks that the stored URL stays the moved one.

…emporary checkpoint sidecar, and reject opaque cloud URIs

An external Delta table reserves _delta_log/<version>.json, which every
Delta table has. A managed Delta table uses V2 checkpoints, whose
sidecar is written to a temporary file of 162 characters before it is
renamed on Azure, so it reserves that. A cloud URI without a bucket or
container, such as s3:a/b, is rejected with INVALID_ARGUMENT. The SDK
tests no longer create an Iceberg table through the native endpoint,
and a URL update is tested with a live credential.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
yili-db pushed a commit that referenced this pull request Nov 25, 2026
**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated (not needed, the docs don't describe column widths)

**Description of changes**

Creating a catalog whose storage root is longer than 255 characters
fails with a 500:

```
POST /api/2.1/unity-catalog/catalogs  {"name": "c", "storage_root": "s3://catalog-bucket/<1000 characters>"}
500 INTERNAL ... Value too long for column "STORAGE_ROOT CHARACTER VARYING(255)"
```

The same happens for a schema storage root, a managed volume whose
catalog or schema location is long enough that
`<location>/volumes/<uuid>` passes 255 characters, an external volume
over 255 characters, and a model version `source` over 255 characters.
Table locations don't have this problem because `uc_tables.url` is
`varchar(2048)`, and staging table locations are 2048 as well.

This PR widens these columns to 2048, the width of `uc_tables.url`, with
one single-statement step per column for H2, MySQL and PostgreSQL, each
with its own effect file, the same way #2187 widens the function
columns:

- V11 `uc_catalogs.storage_root` and V12 `uc_catalogs.storage_location`
- V13 `uc_schemas.storage_root` and V14 `uc_schemas.storage_location`
- V15 `uc_volumes.storage_location`
- V16 `uc_model_versions.source`


The matching DAO fields use one constant,
`Constants.MAX_STORAGE_LOCATION_LENGTH` (2048), which the table url and
staging table location columns now use too. Their width doesn't change.
Each step only changes a column type from `varchar(255)` to
`varchar(2048)`, and all six columns are nullable and have no default,
so the MySQL `MODIFY` restates `NULL` and drops nothing. None of the six
columns is in an index, so no index entry grows.

A new database gets the wider columns from the steps. An existing
database gets them when `bin/start-uc-server --upgrade-schema` runs the
new steps.

The steps are V11 to V16, the next numbers after the V10 step #2187
added, because `SchemaMigratorTest` expects the step versions to have no
gaps. #2260 and #1781 also add a V11, so whichever of these merges
second needs to renumber its steps.

`uc_external_locations.url` is also `varchar(255)`, but it is not
widened here. It has the `idx_url` index on all three databases, and at
2048 characters that index would go over MySQL's 3,072 byte key limit
and PostgreSQL's 2,704 byte index entry limit, which
`MigrationStepRulesTest` refuses. Widening it needs a step that drops or
replaces the index, which the step rules don't allow yet, so it can
follow separately.

**Follow-up**

Location validation against the columns and the cloud limits moved to
its own PR, #2378, which builds on this one. A root that fits its column
can still be too long for the managed locations under it, and that PR
rejects such roots before they are stored.

**Testing**

`SdkManagedLocationTest.testStoragePathsLongerThan255Characters` creates
a 1,020 character catalog root and a 1,219 character schema root and
reads them back. It also creates managed volumes under each, then an
external volume and a model version source of exactly 2,048 characters,
which are read back. On main, each of these fails with a 500.
`SchemaMigratorTest` and `MigrationStepRulesTest` check the new steps on
H2, MySQL and PostgreSQL. `javafmtCheck`, `checkstyle` and
`Test/compile` pass for `server`. The Sdk tests can't start on Windows,
so they run on CI.

---------

Signed-off-by: Maha Rana Yadavalli <[email protected]>
Co-authored-by: Maha Rana Yadavalli <[email protected]>

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Comment at f2af7af. Thanks for fixing the Delta budget, the catch-all, and the two failing tests. Three normal items remain, with inline notes: the Iceberg metadata budget, the credential-only update path, and the read-only check on external locations. The Delta and managed sidecar budgets look right.

if (format == DataSourceFormat.DELTA) {
return DELTA_TABLE;
}
return format == DataSourceFormat.ICEBERG ? PREFIX : OBJECT_OR_PREFIX;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Iceberg tables still use PREFIX, which reserves only a slash and one character under the table location. MetadataService writes a metadata file named with the version and a UUID under the table, so a location near the limit can pass validation and still have no room for its metadata. Ask: add an Iceberg extent sized for that file, like DELTA_TABLE, and a boundary test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added an ICEBERG_TABLE extent in 50e075e. It reserves the manifest list every commit writes, metadata/snap---.avro, 78 characters with a 19 digit snapshot id. That is longer than the 65 character metadata file MetadataService writes. Boundary tests cover the S3 key length and the Azure segments.

validateUrlLimits(existingLocation.getUrl(), Optional.of(credentialDAO));
} else {
// A URL an earlier release stored that no longer parses can still move.
storedUrlToCheck(existingLocation.getUrl())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] A credential-only update re-checks the stored URL against the new credential's limits, so a location created before these limits, with an over-limit URL, cannot have its credential rotated unless the URL also changes. Ask: state this rule in configuration.md and pin it with a test, or check only the rules that depend on the new credential.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed in ffdc4f1. A credential-only update now checks only the AWS STS session policy, the one limit that depends on the credential. A stored URL without a bucket, such as s3:/path, used to block rotation and no longer does. A URL whose policy can't fit the new credential is still rejected, since every vend would fail. configuration.md states the rule, and tests cover both cases.

.<CoveringCredential>map(CoveringCredential.Covered::new)
.orElseGet(CoveringCredential.Deleted::new));
validateLocation(
url, maxLength, columnUnit.get(), Use.REQUESTED, Extent.PREFIX, vendCredential);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] External tables, external volumes and external location URLs are checked only against the read policy (Use.REQUESTED, which is SELECT only). A writable table or volume can pass here and then fail on every write vend, which sends the longer SELECT and UPDATE policy. Ask: validate these with SELECT and UPDATE as managed locations are, or document that a long S3 location is readable but not writable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I kept the documented behavior. configuration.md says a long S3 location can be accepted and read but not written, and that a write vend for it fails with INVALID_ARGUMENT. Checking the write policy would reject long read-only locations that work on main today.

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

useful checks overall, and thanks for addressing the earlier threads. i left two comments, one on iceberg staging table reserves and a small wording fix in the docs.

session,
stagingLocation,
Constants.MAX_STORAGE_LOCATION_LENGTH,
StorageLimits.Extent.MANAGED_DELTA_TABLE);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

iceberg rest table creation without a location also goes through here, so it ends up reserving 162 chars for a delta checkpoint sidecar file and failing with a delta-specific error. should we let the caller pass the extent (keeping MANAGED_DELTA_TABLE for delta and using an iceberg extent from IcebergRestCatalogService) and add a boundary test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in d705b66. createStagingTable now takes the extent. The UC and Delta staging endpoints pass MANAGED_DELTA_TABLE and the Iceberg REST catalog passes ICEBERG_TABLE. RepositoriesTest checks the Iceberg boundary and the Delta message at the same location.

Comment thread docs/server/configuration.md Outdated
policy, which is shorter. A long S3 location can be accepted and read but not written, and a write vend for it fails
with `INVALID_ARGUMENT`. On a GCS bucket the server is configured for without a custom credential generator,
the access boundary it builds has to fit its limit.
- When the storage credential of an S3 or GCS location can't be found, such as after it was force-deleted, only the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

cloud checks still run when no external location covers the path, and are only skipped when a covering location's credential was force-deleted (which also skips the gcs object-name check). could we tighten the wording here?

- - When the storage credential of an S3 or GCS location can't be found, such as after it was force-deleted, only the
-   column width is checked, because a vend then fails on the missing credential.
+ - When a covering external location's S3 or GCS credential was force-deleted, only the column width is checked.
+   This also skips the GCS object-name check. A location with no covering external location still receives the
+   applicable cloud checks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, applied in dcd542a with small wording changes after checking each sentence against the code. Azure locations never look up a credential, so the rule only covers S3 and GCS.

…cations

Signed-off-by: Maha Rana Yadavalli <[email protected]>

# Conflicts:
#	server/src/main/java/io/unitycatalog/server/persist/ModelRepository.java
#	server/src/main/java/io/unitycatalog/server/persist/dao/ModelVersionInfoDAO.java
#	server/src/main/java/io/unitycatalog/server/utils/Constants.java
#	server/src/test/java/io/unitycatalog/server/sdk/managedlocation/SdkManagedLocationTest.java
…ocation

An Iceberg table used the PREFIX extent, which leaves room for a single
character under the location. Every Iceberg commit writes a manifest list,
metadata/snap-<snapshot id>-<attempt>-<uuid>.avro, which is the longest file
name of a fixed length an Iceberg table has (78 characters with the slash,
for a 19 digit snapshot id on the first attempt). The new ICEBERG_TABLE
extent reserves it, and Extent.ofTable uses it for Iceberg tables.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
…ta ones

Creating an Iceberg table through the Iceberg REST catalog without a
location creates a staging table, which was always checked with the managed
Delta extent and rejected with a message about Delta checkpoint sidecars.
The caller now passes the extent: the UC and Delta staging table endpoints
keep MANAGED_DELTA_TABLE, and the Iceberg REST catalog passes ICEBERG_TABLE.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
…s credential changes

A credential-only update checked the stored URL against every limit again.
It now checks only the limits that depend on the new credential, the AWS STS
session policy of an S3 location on AWS. The column width, object name and
URL shape rules depend on the URL alone, so a URL stored before they were
checked can still change its credential.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
@yili-db

yili-db commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

/review

The create requests for catalogs, schemas, volumes, tables and model versions, and the external location create and update requests, now say how long their storage paths can be. Catalog and schema roots also say how much room the managed location suffix needs. The markdown reference pages are regenerated.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
@yili-db

yili-db commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

/review

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks close overall -- left two comments on raw path handling and external iceberg stage-create validation, plus two small nits.

* The object name of a location in its bucket or container: its path without the leading slash.
*/
public static String objectName(NormalizedURL location) {
return CharMatcher.is('/').trimLeadingFrom(location.toUri().getPath());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

to my understanding getPath() decodes percent escapes like %61 and %2f, while the s3, gcs, and azure clients keep them raw in the object name -- so %61 repeated 342 times passes here at 342 chars even though the real name is 1,026 bytes, and a%2f repeated 254 times gets falsely rejected on azure. should we use getRawPath() here (and check the s3 and gcs policy builders too), plus add tests with encoded chars at the boundary and %2f on azure?

-    return CharMatcher.is('/').trimLeadingFrom(location.toUri().getPath());
+    return CharMatcher.is('/').trimLeadingFrom(location.toUri().getRawPath());

"External table storage location must include a non-empty path prefix: %s",
createTable.getStorageLocation());
ExternalLocationUtils.validateNotOverlapWithManagedStorage(session, storageLocation);
repositories

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this check only runs when saving the table, so external iceberg stage-create doesn't hit it and can let a client stage a table and write data before failing on commit (for instance if the initial metadata file fits on azure but the reserved manifest-list name doesn't). should we add a read-only preflight check and call it before external iceberg stage-create prepares the location and before staged commit writes metadata? could we also add boundary tests showing staging fails on an invalid location and succeeds on a valid one?

* Validates a location given in a request, such as an external table or volume location.
*
* @param maxLength the width of the column the location is stored in, in characters
* @param extent {@link Extent#OBJECT_OR_PREFIX} only for a location that may be a single file,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: this comment leaves out the delta and iceberg extents, and validateManagedLocation below says every managed table uses MANAGED_DELTA_TABLE when iceberg uses ICEBERG_TABLE. should we update both javadocs?

-   * @param extent {@link Extent#OBJECT_OR_PREFIX} only for a location that may be a single file,
-   *     such as a CSV table, otherwise {@link Extent#PREFIX}
+   * @param extent {@link Extent#ofTable(DataSourceFormat)} for tables, otherwise
+   *     {@link Extent#PREFIX}

}

private Optional<CredentialDAO> getExternalLocationCredentialDaoForPath(
public Optional<CredentialDAO> getExternalLocationCredentialDaoForPath(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: looks like the only caller of this overload is still inside ExternalLocationUtils -- can we keep it private?

-  public Optional<CredentialDAO> getExternalLocationCredentialDaoForPath(
+  private Optional<CredentialDAO> getExternalLocationCredentialDaoForPath(

This branch has not been deployed

No deployments
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.

3 participants