Skip to content

[Server] Create GCP service account key credentials - #2260

Open
timothyw553 wants to merge 10 commits into
unitycatalog:mainfrom
timothyw553:stack/gcp-credential-create
Open

timothyw553 wants to merge 10 commits into
unitycatalog:mainfrom
timothyw553:stack/gcp-credential-create

Conversation

@timothyw553

@timothyw553 timothyw553 commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


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

Today UC reaches AWS (plus S3-compatible storage, which is experimental), and GCS only through a key file in the server configuration (the gcs.* settings). To support Google Cloud Storage (GCS), an admin needs a way to give UC a Google service account. This PR adds that first half: creating and storing the credential.

Handing out GCS access tokens from it is the next PR, so reading data under a GCS location does not work yet.

What an admin can do now

bin/uc credential create --name my_gcs_cred --gcp_service_account_key_file key.json
bin/uc external_location create --name my_loc --url gs://my-bucket/data --credential_name my_gcs_cred

key.json is the file Google gives you when you create a service account key. The CLI reads three fields from it and sends them in the new gcp_service_account_key object of the create-credential request:

Field in key.json Field in the request In get / list
client_email email returned
private_key_id private_key_id returned
private_key private_key (PEM, PKCS#8) never returned

The request the CLI sends, POST /credentials:

{
  "name": "my_gcs_cred",
  "purpose": "STORAGE",
  "gcp_service_account_key": {
    "email": "[email protected]",
    "private_key_id": "0123456789abcdef",
    "private_key": "<PEM-encoded PKCS#8 private key>"
  }
}

And the response, which is what get and list return too:

{
  "id": "…",
  "name": "my_gcs_cred",
  "purpose": "STORAGE",
  "gcp_service_account_key": {
    "email": "[email protected]",
    "private_key_id": "0123456789abcdef"
  },
  "owner": "…",
  "created_at": 1763000000000,
  "created_by": "…"
}

All three are required. The other fields in the file (project_id, client_id, token_uri and so on) are not used.

How it works

  • The private key is encrypted in the database the same way the S3-compatible secret already is (#2171). That needs the server's encryption key (UC_SERVER_CREDENTIAL_ENCRYPTION_KEY); without it, creating the credential fails with a message saying so. One change to #2171's behavior: that key used to be read only when S3-compatible storage was turned on, and is now read whenever it is set.
  • External locations of a GCS credential must be gs://
  • A new database migration (V11) lets H2, MySQL and PostgreSQL store the new credential type.
  • The credential cache is keyed by a stored GCP credential's id and key fingerprint, so a token cached for the server's gcs.* settings is never served for a path that a GCP credential now covers.
  • Startup change: the server now reads server.credential-encryption-key whenever it is set, and warns about unreadable stored secrets for every deployment, not only S3-compatible ones. A set key that is malformed now stops any server, including AWS-only ones. Release-note worthy.
  • The API spec, generated API docs and CLI docs are updated.

Known limitations

  • Replacing the key of an existing credential is not supported: create a new credential and point the external locations at it. Tracked in #2275.
  • Nothing in this PR contacts Google. UC checks that the email and key ID are present and within the length limits and that the private key parses, but not that Google accepts them. Real-GCS testing is in [Server] Vend GCS credentials from storage credentials #2273.

Testing

The full server and CLI tests on H2. The credential, external location and migration tests on PostgreSQL 18 and MySQL 8.

@timothyw553
timothyw553 force-pushed the stack/gcp-credential-create branch from 7abb9c9 to 31830b7 Compare November 17, 2026 17:18
yili-db pushed a commit that referenced this pull request Nov 19, 2026
…icit dir repair off for vended tokens (#2281)

## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2281/files) to
review incremental changes.
-
[stack/gcs-hadoop-conflict-check](#2281)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2281/files)]

---------
**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [x] 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!
- [x] If you've added or modified a feature, documentation in `docs` is
updated

**Description of changes**

Fixes [#2278](#2278):
reading or writing a table on `gs://` through Unity Catalog failed on
Spark 4.2 and 4.3 with `403` errors from Google.

**Why it failed.** The token Unity Catalog vends only covers the table's
own folder. Google's GCS connector has three settings that make it touch
things outside that folder:
- `fs.gs.create.items.conflict.check.enable` reads every folder above a
new file or folder, so creating a table or writing to it fails. Unity
Catalog already tried to turn it off, but Hadoop 3.5 started shipping it
as "on" in its own defaults, and our code took that default for the
user's choice.
- `fs.gs.hierarchical.namespace.folders.enable` reads the bucket's
layout when a folder is deleted or renamed. The connector turns it on
itself, on every Spark version. Parquet tables fail because their commit
deletes folders; Delta tables do not.
- `fs.gs.implicit.dir.repair.enable` looks up the parent folder after a
folder is deleted, for example by `INSERT OVERWRITE` on a parquet table.
The connector turns it on itself, on every Spark version.

**The fix**
- All three are now off on every Spark version, unless the user turns
one on themselves (for example with broader credentials, or on a
hierarchical-namespace bucket).
- The Spark docs now use Google's connector 4.0.10 on every Spark
version. Hadoop 3.5's own GCS module can't take a vended token, and the
old 3.0.2 jar doesn't work on Spark 4.2. With 4.0.10, Spark 4.1 also no
longer needs the workaround in
[#2277](#2277).
- The docs also show the settings for releases before 0.8.0, which don't
have this fix. The Spark 4.0.x and 4.1.x commands set the hierarchical
namespace and implicit directory repair settings; the 4.2.x command also
sets the conflict check, because only Hadoop 3.5 turns it on.
- With the hierarchical namespace setting off, folder delete and rename
on hierarchical-namespace buckets lose the connector's native folder
path until users set it back to `true`.
- `engineSets` moved from the S3 builder into `CredPropsBuilder` (moved
with a generalized comment; S3 behavior is unchanged). The GCS-only
`setOffUnlessEngineSets` stays in `GcsCredPropsBuilder`.
- The docs also add a short note on Structured Streaming: a checkpoint
location gets no Unity Catalog credentials, so the session needs its own
access limited to that location.

**Testing**
- New unit tests; the existing ones still pass. The unit tests in this
repo still use connector 3.0.2 on purpose; the real-GCS runs below use
4.0.10.
- On a real GCS bucket, with Spark 4.0, 4.1, 4.2 and 4.3 and connector
4.0.10, using a Unity Catalog server that vends GCS credentials
([#2260](#2260),
[#2273](#2273)): Delta
and parquet tables, managed tables, and path reads and writes in Spark
SQL all work. A Spark session also kept working past the one-hour token
expiry.
- On Spark 4.0 and 4.1, turning any of them on by hand makes tests fail:
the bucket-layout one breaks non-Delta table writes, the folder one
breaks everything, the folder-repair one breaks `INSERT OVERWRITE` on
parquet tables.

**Not covered.** Reading a bare `gs://` path with the DataFrame API
(`spark.read.parquet("gs://...")`) doesn't use Unity Catalog credentials
on any version. This PR doesn't change that.

---------

Signed-off-by: Timothy Wang <[email protected]>
Co-authored-by: Isaac <[email protected]>

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

overall looks clean and focused. left a few comments on the MySQL skip, the startup scan gate, cache key binding, and some test/doc gaps.

@timothyw553
timothyw553 force-pushed the stack/gcp-credential-create branch from 31830b7 to 0c04f38 Compare November 19, 2026 09:48

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

mostly docs and test nits left on top of the open MySQL and cache threads. left a few comments on updating the encryption-key docs, noting that token vending isn't wired up yet, and a couple of edge-case tests.

Comment thread docs/usage/cli.md Resolved
@timothyw553

Copy link
Copy Markdown
Collaborator Author

The MySQL and PostgreSQL CI failures came from my earlier changes, and are fixed in b4c29b0: the GCP credential test is now skipped on MySQL until #2169 (the key does not fit the 255-byte column), and the schema migrator test now leaves every step after 2 pending, so a later step like V4 does not break it. I ran the full server suite on both databases locally; the only failure was a port clash with a local server.

@timothyw553
timothyw553 force-pushed the stack/gcp-credential-create branch from b4c29b0 to 0c4a496 Compare November 20, 2026 02:21
@timothyw553
timothyw553 marked this pull request as ready for review November 20, 2026 08:45
@timothyw553
timothyw553 force-pushed the stack/gcp-credential-create branch from 0c4a496 to 69508a2 Compare November 20, 2026 09:20
@yili-db

yili-db commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

/review

@timothyw553
timothyw553 force-pushed the stack/gcp-credential-create branch from 69508a2 to 1614880 Compare November 20, 2026 23:53
@timothyw553

Copy link
Copy Markdown
Collaborator Author

Addressed: the cache key for a stored GCP credential now lives in this PR, with a test that a token cached for the gcs.* settings does not serve a stored GCP credential, plus a test that vending from a stored credential is UNIMPLEMENTED until the next PR. The three docs that described the encryption key as S3-compatible-only are updated, the create-credential text in the spec says gs://, the key requirement and that vending is not there yet, and the startup change is in the description. I left key rotation to #2275 and the other test and refactoring notes.

@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] Review of 1614880c: comment. Inline items are the length limits and a test nit. Body items are a follow-up link and a description typo. Nothing else is blocking.

Follow-up: replacing the key on update is needed, but it can be a separate change. Issue #2275 already tracks it. Could we link #2275 from this PR's description so the limitation has an owner?

nit: the description has "xternal locations" (missing the E) in the line about gs:// paths.

@shba24
shba24 self-requested a review November 21, 2026 01:05
Comment thread docs/usage/cli.md Resolved
@maharanay22 maharanay22 mentioned this pull request Nov 21, 2026
2 of 4 tasks
@timothyw553
timothyw553 force-pushed the stack/gcp-credential-create branch from 1614880 to 9df0c80 Compare November 22, 2026 00:46
@timothyw553

Copy link
Copy Markdown
Collaborator Author

Addressed: length limits on the key fields, the Javadoc, and the temp file delete. The description now links #2275 and the typo is fixed.

@yili-db

yili-db commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

/review

@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] Re-review at 9df0c80.

Addressed: the length limits, the Files.deleteIfExists change in the CLI test helper, and the link to #2275 in the description.

Normal:

  • The first paragraph says UC can only be pointed at AWS today. The server already serves GCS locations from the gcs.* settings, so this sentence should say that a GCS location today uses a key file in the server configuration, and that this PR adds a key per credential.
  • The description says UC only checks that the private key parses. It also checks that the email and key ID are present and within the length limits, so that sentence should say so.

Followup (not for this PR, please track it in an issue): a malformed request body can have its text quoted in the error response on the UC, AUTH, SCIM and DELTA surfaces (the comment in ArmeriaServerBuilder says so). This also applies to the s3_compatible secret. A follow-up issue could cover a sanitized body error for credential bodies.

"Storage credential '%s' is a gcp_service_account_key credential, so aws_iam_role and"
+ " s3_compatible cannot be set on it.",
name);
// Every part of a credential can change while external locations use it, including its

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] This comment says every part of a credential can change, including its type. The guard above now stops a gcp_service_account_key credential from changing type, so could the comment say that, or move below the guard?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reworded: it now says an aws_iam_role or s3_compatible credential can change in every part, so it no longer contradicts the guard above it.

@timothyw553

Copy link
Copy Markdown
Collaborator Author

Description fixed: the intro now says a GCS location uses a key file in the server configuration today, and the last note says what the server checks. The malformed request body being quoted in errors is a separate follow-up.

@yili-db

yili-db commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

/review

@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] Re-review at 40fd3ca.

Earlier items N1 to N5 are addressed: the intro and the limits sentence in the description, the stale comment in CredentialRepository, the 1024 and 4096 boundary cases, and the enum-order comment.

We also missed two items in earlier rounds, which are part of this PR: the Helm section title and the spec maxLength and writeOnly lines. The inline comments cover the spec and helm/values.yaml. The Helm template itself (helm/README.md.gotmpl, section "S3-compatible storage credentials", around line 51) is outside this diff, so it is listed here: the section and its title only describe s3_compatible, and the link from helm/values.yaml points to it.

Still open:

  • No test creates a GCP credential with server.s3-compatible-storage.enabled off. BaseServerTest.java:99 enables it for every server test, so the claim that a GCP-only server works is not pinned by a test. A create case with the flag off would cover it.
  • The N6 follow-up (quoted request bodies in error responses) is described as a separate follow-up, but no issue is linked yet. Could you link the issue?

Optional nit: with S3 disabled, an s3_compatible update of a GCP credential returns the S3-disabled message instead of a GCP one, because the flag check (CredentialRepository.java:163-166) runs before the GCP guard. Moving the GCP check first would fix the message.

Comment thread api/all.yaml Resolved
Comment thread api/all.yaml Resolved
Comment thread helm/values.yaml Resolved
@timothyw553

Copy link
Copy Markdown
Collaborator Author

Added GcpOnlyServerCredentialTest: a server with the encryption key set and S3-compatible storage off creates and reads a gcp_service_account_key credential, and an s3_compatible create is refused as disabled.

The parser text returned for a malformed request body is tracked in #2352.

Left as is: with S3 off, an s3_compatible update of a GCP credential returns the S3-disabled message, since the flag check runs before the credential is loaded. Moving it after the GCP guard would also change what a missing credential returns on those servers, so I would rather not do that here.

@shba24 shba24 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.

Reviewed at 8e64ccf: no issues found.

@timothyw553
timothyw553 force-pushed the stack/gcp-credential-create branch from 8e64ccf to a0afe36 Compare November 23, 2026 21:07
@timothyw553

Copy link
Copy Markdown
Collaborator Author

/review

@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] Approving at ec8cbdd. The length limits, the write-only private key in the spec, the Helm section and the test with S3 storage disabled are all in place, and the private key is stored the same way as the s3_compatible secret. Non-blocking: please link the tracking issue for the quoted-request-body follow-up from the description.

@shba24 shba24 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.

On code this pull request does not change

server/src/test/java/io/unitycatalog/server/service/credential/CloudCredentialVendorTest.java:99

Nit (not a blocker): Test comment says the encryption key is read only with S3-compatible storage on, but it is now always read

EncryptedCredentialSecretStore.from (lines 53-55) now reads server.credential-encryption-key whenever it is set, with no check of server.s3-compatible-storage.enabled. The comment in CloudCredentialVendorTest.setUp still describes the gate this change removed, so a reader may think the S3 flag stub on the next line is what makes key loading work.

For example: With server.credential-encryption-key set and server.s3-compatible-storage.enabled=false, the key is still loaded (EncryptedCredentialSecretStoreTest.testKeyIsReadWhenSet), which contradicts the comment. This is the only stale statement of this kind I found; the docs, properties file and Helm values already describe the new behavior.

Delete the sentence 'The key is read only with s3-compatible storage enabled.' If the isS3CompatibleStorageEnabled stub is still needed, say it is for the S3-compatible paths and not for loading the key.

Evidence
`server/src/test/java/io/unitycatalog/server/service/credential/CloudCredentialVendorTest.java:99`: `// The key is read only with s3-compatible storage enabled.` This is stale: `server/src/main/java/io/unitycatalog/server/persist/secret/EncryptedCredentialSecretStore.java:54-55` reads the configured key without checking the S3 flag.
How it was checked

Disprovers agreed (CONFIRMED): codex

How about dropping that sentence so the comment matches EncryptedCredentialSecretStore.from?

"FROM CredentialDAO WHERE credentialType = :type", CredentialDAO.class);
query.setParameter("type", CredentialDAO.CredentialType.S3_COMPATIBLE);
"FROM CredentialDAO WHERE credentialType IN :types", CredentialDAO.class);
query.setParameterList(

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 (not a blocker): Per-type secret and scheme facts are spread over several files

With a second secret-bearing credential type, each fact about a type now has its own branch: the IN list and if/else in listUnreadableSecrets, WRITE_ONLY_FIELDS in CredentialDAO, the type filter in CachingCloudCredentialVendor.Key.from, and the scheme if/else in ExternalLocationRepository.validateUrlForCredential (line 85). Everything is correct for the two types that exist; the else branch calls getGcpPrivateKey, which rejects a wrong-type credential (CredentialDAO.java:195-198), so a missed branch would be logged as unreadable, not read silently.

Cost of keeping it: When Azure (a TODO in toCredentialInfo) lands, it needs matching edits in CredentialRepository, CachingCloudCredentialVendor, ExternalLocationRepository and CredentialDAO. A missed site could go unnoticed, for example a credential cached without its version or a location accepted on any scheme.

Optional, or as a follow-up: have CredentialDAO read its own secret so listUnreadableSecrets has no type if/else. Add requiredScheme() and a has-stored-secret check on CredentialType when the third type arrives. Keeping the GCP update guard and cache policy where they are avoids growing this PR.

Evidence
CredentialRepository.java:275-288 holds the list of types that carry a secret and a separate if/else that picks the accessor, with GCP as the catch-all `else`: `"FROM CredentialDAO WHERE credentialType IN :types"` … `List.of(CredentialDAO.CredentialType.S3_COMPATIBLE, CredentialDAO.CredentialType.GCP_SERVICE_ACCOUNT_KEY));` … `if (dao.getCredentialType() == CredentialDAO.CredentialType.S3_COMPATIBLE) { dao.getS3SecretAccessKey(secretStore); } else { dao.getGcpPrivateKey(secretStore); }`. CachingCloudCredentialVendor.java:181-185 repeats the same set of types: `.filter(dao -> dao.getCredentialType() == CredentialType.S3_COMPATIBLE || dao.getCredentialType() == CredentialType.GCP_SERVICE_ACCOUNT_KEY)`. CredentialDAO.java keeps a third copy as field names: `private static final List<String> WRITE_ONLY_FIELDS = List.of(SECRET_ACCESS_KEY_FIELD, PRIVATE_KEY_FIELD);`. ExternalLocationRepository.java:85-99 maps type to scheme: `if (credentialDAO.getCredentialType() == CredentialType.S3_COMPATIBLE) { ... NormalizedURL.isS3Path(url) ... } else if (credentialDAO.getCredentialType() == CredentialType.GCP_SERVICE_ACCOUNT_KEY) { ... NormalizedURL.isGsPath(url) ...`. CredentialDAO.toCredentialInfo already switches on the type and names the next type: `case GCP_SERVICE_ACCOUNT_KEY: ... // TODO: support Azure.`. Each of these sites encodes the same per-type fact independently, so nothing keeps them in step when another type is added.
How it was checked

Disprovers agreed (NITPICK): codex

Would you prefer to leave this for the Azure change, or move the secret read into the DAO now?

String missing = "gcp_service_account_key.%s is required.";
List<InvalidCreate> invalidCreates =
List.of(
new InvalidCreate(

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 (not a blocker): No invalid-create row for GCP key together with S3-compatible fields

The rule is one symmetric count over aws, s3 and gcp (CredentialDAO.java:143-153), and rows exist for AWS+S3, AWS+GCP and no field. GCP+S3-compatible is the one missing pair. A change to the count itself would already fail an existing row, so this only guards a future rewrite into pairwise checks.

For example: Someone rewrites the check into separate pairwise checks and leaves out GCP+S3. A create request with both gcp_service_account_key and s3_compatible would then be accepted with no failing test.

Add a GCP+S3-compatible row to the invalid-create list and run it with S3-compatible storage on, so it hits the 'Specify exactly one of aws_iam_role, s3_compatible and gcp_service_account_key.' message and not the S3-disabled check in CredentialRepository.java:67-69.

Evidence
CredentialDAO.java:143-150 counts awsIamRole, s3Compatible, and gcpServiceAccountKey and requires the count to equal 1. BaseCredentialCRUDTest.java:319-321 tests GCP together with AWS, but the GCP and S3-compatible combination is absent from the credential tests.
How it was checked

Disprovers split: codex CONFIRMED, opus DISPROVED

Is it worth adding this row, with S3 on so it reaches the right error?

context.getS3Endpoint(),
context.getS3Region(),
context.isServerAccess() && s3CompatibleVersion.isPresent());
context.isServerAccess() && isS3Compatible);

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 (not a blocker): No test shows a GCP credential shares one cache entry between server and client vends

The key's isServerAccess part is context.isServerAccess() && isS3Compatible, so GCP credentials share one entry for server and client access. The new GCP rows vary only the credential id and fingerprint, and the GCP context helper always passes isServerAccess=false. The only server/client cases (around lines 742-773) cover S3-compatible and AWS.

For example: A change derives the flag from the credentialVersion filter, so it is also true for GCP. Two vends of the same GCP credential, one with isServerAccess=true and one with false, would then create two cache entries and two cloud vends, and no test would fail.

In CachingCloudCredentialVendorTest, next to the S3-compatible server/client case, add a GCP case: same credential id and fingerprint, vend once with isServerAccess=true and once with false, and expect a single underlying vend.

Evidence
server/src/main/java/io/unitycatalog/server/service/credential/CachingCloudCredentialVendor.java:199 `context.isServerAccess() && isS3Compatible);` The new rows in CachingCloudCredentialVendorTest build `gcpCtx(...)` with CredentialContext.create(GCS_LOC, READ_ONLY, Optional.of(dao)). Every row changes the credential id or the fingerprint. None compares a server-access context with a client context for the same GCP credential, so widening `isS3Compatible` to include GCP, or dropping it, changes no test result.
How it was checked

Disprovers agreed (CONFIRMED): codex

How about adding that GCP mirror of the S3-compatible case?

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]>

@shba24 shba24 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.

On lines this pull request does not change

server/src/main/java/io/unitycatalog/server/service/credential/gcp/GcpCredentialVendor.java:48

Nit (not a blocker): The vending error describes a valid GCP binding as unsupported

The service overview and the runtime diagnostic both describe GCP credential management as unavailable. At this head only vending a token from the stored credential is unavailable. This is one bug class: Text written when GCP credentials were not implemented at all was kept after this change added GCP credential management, so it now says too much is unsupported. The same issue appears in server/src/main/java/io/unitycatalog/server/service/CredentialService.java:39 (The service overview Javadoc lists GCP as 'Not implemented yet'.).

For example: A user can create a GCP credential and bind a gs:// location successfully. Their next access request says Storage credential/external location for GCP is not supported yet.

Narrow the diagnostic to token vending from a stored GCP credential. Describe service account key storage and location binding in the service overview.

Evidence

The service overview says GCP is unimplemented and the vendor's public error says GCP storage credentials and external locations are unsupported. The changed DAO stores those credentials, and the external-location repository expressly accepts bindings to them. Only token vending remains unavailable.

How it was checked

Reproduced: python3 dev/run-tests.py "server/testOnly io.unitycatalog.server.service.credential.gcp.GcpCredentialVendorTest"

head:

io.unitycatalog.server.service.credential.gcp.GcpCredentialVendorTest#testGateDiagnosticDescribesVendingOnly(): java.lang.AssertionError: Expecting actual: "Storage credential/external location for GCP is not supported yet." to contain: "vend" (ignoring case) (GcpCredentialVendorTest.java:95). Total 16, Failed 1, Passed 15

Checked by 1 independent check: CONFIRMED

Could we name token vending in the error and update the GCP entry in CredentialService to match?

* @return whether {@code url} is a {@code gs://} path with a bucket
*/
public static boolean isGsPath(String url) {
return isBucketPath(url, UriScheme.GS);

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.

Blocker: A GCP external location can be saved with an unreadable bucket name

isGsPath examines the raw authority for @ and :. The credential reader later reconstructs the storage base from the decoded authority, so an escaped space passes the write check and fails on read. This is one bug class: The bucket check on a location URL reads the raw (percent-encoded) authority and only rejects '@' and ':', while the vend path rebuilds the URL from the decoded authority, so a bucket that is invalid for the provider is accepted at create time and fails later. The same issue appears in server/src/main/java/io/unitycatalog/server/utils/NormalizedURL.java:116 (isGsPath accepts gs://bad%20bucket/data. getStorageBase() (NormalizedURL.java:334) uses the decoded authority and throws 'Unsupported path: gs://bad bucket' whe); server/src/main/java/io/unitycatalog/server/utils/NormalizedURL.java:116 (isGsPath ignores GCS limits other than '@' and ':'. It accepts uppercase letters, 1-2 or 64+ character names, and other characters GCS forbids, so names that ca); server/src/main/java/io/unitycatalog/server/utils/NormalizedURL.java:105 (isS3Path shares the same check, so an s3_compatible location at s3://bad%20bucket/x passes and getStorageBase later fails in AwsCredentialVendor or FileOperatio); server/src/main/java/io/unitycatalog/server/persist/CredentialRepository.java:322 (validateLocationsAreS3Paths, called on s3_compatible credential update, uses the same isS3Path, so updating a credential re-accepts locations with encoded or in).

For example: An admin creates gs://bad%20bucket/data. Creation succeeds, but the credential reader fails on gs://bad bucket when it builds the storage base.

Validate the GCS bucket authority against the provider's bucket-name syntax on create and update. Preserve valid underscores and keep object-path escaping separate from bucket validation.

Evidence

I checked normalization, the reserved-prefix and overlap guards, the locked credential lookup, and the create/update validation. On H2, creation persisted gs://bad%20bucket/data. The GCP check examines the raw authority, while the unchanged storage-base reader reconstructs a URL from the decoded authority. Calling that reader on the stored URL raised 'Unsupported path: gs://bad bucket'.

How it was checked

Reproduced: dev/run-tests.py "server/testOnly io.unitycatalog.server.utils.NormalizedURLTest"

head:

[error] Test io.unitycatalog.server.utils.NormalizedURLTest.testGsGateAcceptedBucketHasParsableStorageBase failed: io.unitycatalog.server.exception.BaseException: Unsupported path: gs://bad bucket, took 0.024s
[error] Failed: Total 28, Failed 1, Errors 0, Passed 27
(at io.unitycatalog.server.utils.NormalizedURL.normalize(NormalizedURL.java:204))

Checked by 2 independent checks: CONFIRMED

References:

Could isGsPath reject invalid bucket authorities before the location is committed?

}
JsonNode key;
try {
key = new ObjectMapper().readTree(new File(path));

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.

Blocker: A malformed key file can register the wrong service account

The default ObjectMapper stops after the first JSON value. The existing sanitized parse error is never reached when another complete key object follows it.

For example: An operator appends a replacement key object to the old key file and runs credential create. The old key is submitted, and the replacement object is ignored.

Suggested change
key = new ObjectMapper().readTree(new File(path));
key = new ObjectMapper()
.enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)
.readTree(new File(path));
Evidence

The file reader uses a default ObjectMapper and immediately extracts the fields of the returned tree. No subsequent code checks for trailing input before sending the request. With the pinned Jackson version, reading two consecutive objects returned the first object's key ID.

How it was checked

Reproduced: build/sbt -J-Xmx3G "cli/testOnly io.unitycatalog.cli.credential.CliCredentialCRUDTest"

head:

[error] Test io.unitycatalog.cli.credential.CliCredentialCRUDTest.testConcatenatedKeyFileIsRejected failed: java.lang.AssertionError: Expecting code to raise a throwable. ... Failed: Total 8, Failed 1, Errors 0, Passed 7

Checked by 2 independent checks: CONFIRMED

References:

Could the key-file reader require exactly one JSON value?

@@ -0,0 +1 @@
ALTER TABLE uc_credentials MODIFY COLUMN credential_type enum ('AWS_IAM_ROLE', 'GCP_SERVICE_ACCOUNT_KEY', 'S3_COMPATIBLE') not null;

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 (not a blocker): MySQL copies the credentials table during this upgrade

The MySQL enum previously ended with S3_COMPATIBLE. Inserting a member in the middle renumbers existing members, whereas the alphabetical-order comment concerns the PostgreSQL check.

For example: On a database with existing credential rows, inserting GCP_SERVICE_ACCOUNT_KEY before S3_COMPATIBLE requires a copy of uc_credentials while the servers are stopped.

Check whether the MySQL migration and effect can append the member while keeping the entity-schema comparison consistent.

Evidence

V3 placed S3_COMPATIBLE second. V11 inserts the new value before it. The DAO comment explains the alphabetical choice for PostgreSQL, while MySQL documents a table copy for insertion in the middle. The repository's upgrade procedure stops servers before applying the step.

How it was checked

Checked by 1 independent check: CONFIRMED

References:

Would appending the member in the MySQL migration work with the schema comparison?

ErrorCode.INVALID_ARGUMENT,
c.error());
}
// A rejected key is left out of the message.

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 (not a blocker): The test that a rejected private key stays out of the error message would still pass if the library's message leaked through

validateGcpServiceAccountKey replaces the parse error with a fixed message so no part of the key reaches the caller. The test feeds not-a-key and checks that the body does not contain not-a-key.

The pinned google-auth 1.52.0 rejects not-a-key with Invalid PKCS#8 data., which never quotes the input. So the check passes whether or not the fixed message is there. This is one bug class: The secret-not-echoed assertion uses an input the parser never quotes, so it would still pass if the parser's message reached the caller. The same issue appears in server/src/test/java/io/unitycatalog/server/base/credential/BaseCredentialCRUDTest.java:339 (Changing the catch block to append e.getMessage() keeps this test green. A PEM with a bad character would then leak 'BaseEncoding$DecodingException: Unrecognize); server/src/test/java/io/unitycatalog/server/base/credential/BaseCredentialCRUDTest.java:331 (The invalid-create row for the parse error matches by substring (assertApiException contains), so a message with the parser text appended still matches.).

For example: Change the catch block to "... private key: " + e.getMessage() and the test still passes. A PEM body with a bad character would then return com.google.common.io.BaseEncoding$DecodingException: Unrecognized character: ! to the caller: an internal class name plus a character of the key.

// A rejected key, and the parser's own message about it, stay out of the response.
String badPem = "-----BEGIN PRIVATE KEY-----\nMIIB!x\n-----END PRIVATE KEY-----\n";
assertThatThrownBy(() -> credentialOperations.createCredential(gcpRequest(badPem)))
    .isInstanceOf(ApiException.class)
    .extracting(e -> ((ApiException) e).getResponseBody())
    .asString()
    .doesNotContain("DecodingException")
    .doesNotContain("MIIB");
Evidence

The production catch block returns a fixed message with the comment 'The key is not part of the message'. The test checks only that not-a-key is absent from the body. Running google-auth 1.52.0 (build.sbt:458) locally: fromPkcs8(..., "not-a-key", ...) throws java.io.IOException: Invalid PKCS#8 data., and a PEM body MIIBSECRET!!@@ throws java.lang.IllegalArgumentException: com.google.common.io.BaseEncoding$DecodingException: Unrecognized character: !. So the assertion passes whether or not the fixed message is used.

How it was checked

Checked by 1 independent check: CONFIRMED

Would an input the parser actually quotes work better here, so the check can fail?

} else {
throw new BaseException(
ErrorCode.INVALID_ARGUMENT, "Specify exactly one of aws_iam_role and s3_compatible.");
dao.setGcpServiceAccountKey(createRequest.getGcpServiceAccountKey(), secretStore);

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 (not a blocker): Omitting the optional purpose makes GCP credential creation fail

The create schema requires only name. The GCP branch copies the omitted purpose into a non-nullable column, while the CLI explicitly supplies STORAGE and avoids this path.

For example: A REST client sends name and a valid gcp_service_account_key. With encryption configured, H2 rejects the null purpose and the caller gets HTTP 500 for a request the schema permits.

Fix this outside this PR, in the shared CredentialDAO.from / addCredential path: default an omitted purpose to STORAGE for every credential type, or reject it with INVALID_ARGUMENT. Don't special-case gcp_service_account_key.

Evidence

CreateCredentialRequest requires only name and supplies no purpose default. The DAO copies the nullable purpose before selecting the new GCP branch. CredentialRepository validates the name, builds the DAO, and persists it. The database requires purpose, and the transaction error mapping falls back to INTERNAL. The H2 repository probe returned INTERNAL with a valid key and omitted purpose.

How it was checked

Reproduced: dev/run-tests.py "server/testOnly io.unitycatalog.server.sdk.storagecredential.SdkCredentialCRUDTest"

head:

[error] Test SdkCredentialCRUDTest.testGcpCreateWithoutPurpose failed: ApiException: createCredential call failed with: 500 - {"error_code":"INTERNAL",... "message":"Failed to add storage credential: not-null property references a null or transient value : io.unitycatalog.server.persist.dao.CredentialDAO.purpose"}
[error] Failed: Total 7, Failed 2, Errors 0, Passed 5
Also failed identically: testAwsCreateWithoutPurpose (aws_iam_role, purpose omitted).

Checked by 2 independent checks, which split: CONFIRMED, DISPROVED

Could the GCP create path supply STORAGE when the optional purpose is absent?

Comment thread api/all.yaml
$ref: '#/components/schemas/AwsIamRoleRequest'
s3_compatible:
$ref: '#/components/schemas/S3CompatibleRequest'
gcp_service_account_key:

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 (not a blocker): Typed UI callers cannot send or read a GCP credential

The OpenAPI spec defines the field on both create and response models. The catalog types checked into the UI still omit it from both.

For example: A CreateCredentialRequest literal with gcp_service_account_key produces TS2353. Accessing the field on CredentialInfo produces TS2339, so both sides of a typed create call fail to compile.

Optionally regenerate ui/src/types/api/catalog.gen.ts with the existing generate:catalog script (bunx openapi-typescript), in a separate housekeeping PR. That catches up s3_compatible as well. Never hand-edit the file.

Evidence

The catalog spec adds the field on requests and responses. The checked-in TypeScript schema omits it from both. Compiling an object literal produced TS2353, and reading the response property produced TS2339. The UI package defines the generator for this exact spec and output path.

How it was checked

Reproduced: node /tmp/gcp-gate-4102/ts442/package/bin/tsc --noEmit --skipLibCheck --lib es2020,dom ui/src/types/api/catalog.gcp.test.ts (TypeScript 4.4.2, the version pinned in ui/package.json)

head:

Version 4.4.2
ui/src/types/api/catalog.gcp.test.ts(8,3): error TS2322: Type '{ name: string; gcp_service_account_key: {}; }' is not assignable to type '{ name: string; comment?: string; aws_iam_role?: { role_arn: string; }; purpose?: CredentialPurpose; }'.
  Object literal may only specify known properties, and 'gcp_service_account_key' does not exist in type ...
ui/src/types/api/catalog.gcp.test.ts(12,15): error TS2339: Property 'gcp_service_account_key' does not exist on type '{ name?: string; aws_iam_role?: {...}; comment?: string; owner?: string; ... purpose?: CredentialPurpose; }'.
exit=2

with the fix:

Control: the same fixture using aws_iam_role instead of gcp_service_account_key compiles with exit=0. The regenerated-types fix was not run, because it needs bun and openapi-typescript.

Checked by 2 independent checks, which split: CONTESTED, DISPROVED

Could the catalog types be regenerated alongside the API models?

Comment thread api/all.yaml
Set exactly one of `aws_iam_role`, `s3_compatible` and `gcp_service_account_key`; otherwise the
request fails with `INVALID_ARGUMENT`.

A `gcp_service_account_key` credential holds a Google Cloud service account key: the server

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 (not a blocker): Without a gate, a release containing only this layer offers a GCP credential that cannot serve data

s3_compatible is marked EXPERIMENTAL and gated by server.s3-compatible-storage.enabled. gcp_service_account_key is available on every server, but in this layer vending under its locations returns UNIMPLEMENTED.

The repository guide says an API addition is hard to remove once added.

For example: If this PR is released before [Server] Vend GCS credentials from storage credentials (#2273), admins can create credentials and bind gs:// locations that every read fails on. The request fields and the stored blob layout also become a compatibility surface before vending has used them.

Evidence

The spec says the new type is only stored and that vending fails UNIMPLEMENTED. s3_compatible, right after it, is EXPERIMENTAL and gated by a server property. I found no gate for GCP in CredentialRepository (lines 68 and 163 check only s3_compatible). AGENTS.md says additions are hard to remove.

How it was checked

Checked by 1 independent check: NITPICK

Is the plan to merge this together with #2273 in the same release, or would an EXPERIMENTAL note or a gate be worth adding until then?

Comment thread api/all.yaml
private_key_id:
$ref: "#/components/schemas/GcpPrivateKeyId"
private_key:
description: The PEM-encoded PKCS#8 private key of the service account key. Write-only; never returned.

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 (not a blocker): A correctly encoded non-RSA key gets an encoding error

The API calls for PKCS#8 PEM, while the parser specifically expects RSA. The schema also marks email and private_key_id required without describing the nonblank check. The request documentation omits conditions the server enforces. This is one bug class: Validator requirements stricter than the schema (RSA only, non-blank identifiers) are missing from the spec, and the catch-all error names the wrong cause. The same issue appears in server/src/main/java/io/unitycatalog/server/persist/dao/CredentialDAO.java:522 (A valid EC PKCS#8 key gets 'is not a PEM-encoded PKCS#8 private key', which is wrong for that caller.); api/all.yaml:3209 (GcpServiceAccountEmail and GcpPrivateKeyId are plain required strings. The schema does not say they must be non-blank, but the validator rejects whitespace-only).

For example: The pinned parser rejects a generated EC key encoded as PKCS#8 PEM. UC then says it is not a PEM-encoded PKCS#8 private key, which points the caller toward re-encoding the same key.

Specify a PEM-encoded PKCS#8 RSA private key, describe both identifiers as nonblank, regenerate the model docs and align the invalid-key diagnostic.

Evidence

I checked the create-operation description, GCP component schemas and generated model page. They describe required strings and a PEM-encoded PKCS#8 key. The DAO also rejects whitespace-only identifiers and uses an RSA-specific parser. With a generated EC key in PKCS#8 PEM, the pinned parser threw IOException, which the DAO translates into a claim that the encoding is wrong.

How it was checked

Reproduced: dev/run-tests.py "server/testOnly io.unitycatalog.server.persist.dao.CredentialDAOTest"

head:

[error] Test io.unitycatalog.server.persist.dao.CredentialDAOTest.testGateEcPkcs8Contract failed: java.lang.AssertionError:
[error] Failed: Total 9, Failed 1, Errors 0, Passed 8
CredentialDAOTest#testGateEcPkcs8Contract(): java.lang.AssertionError: Expecting throwable message: "gcp_service_account_key.private_key is not a PEM-encoded PKCS#8 private key." to contain: "RSA" but did not. (at CredentialDAO.validateGcpServiceAccountKey(CredentialDAO.java:309))

Checked by 1 independent check: CONFIRMED

References:

Could we name RSA in the field description and error, and make the nonblank identifier requirement explicit?

key.getEmail() != null && !key.getEmail().isBlank(),
"gcp_service_account_key.email is required.");
ValidationUtils.checkArgument(
key.getPrivateKeyId() != null && !key.getPrivateKeyId().isBlank(),

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 (not a blocker): A GCP credential with a blank private_key_id could be accepted, and no test would notice

Each of the three key fields is checked for both null and blank. The test rows cover a blank email, a null private_key_id and a null private_key, so the blank half of the private_key_id check has no row. This is one bug class: Per-field checks of the new GCP validator have no test row for every field and form, so deleting one check goes unnoticed. The same issue appears in server/src/main/java/io/unitycatalog/server/persist/dao/CredentialDAO.java:505 (Dropping !key.getPrivateKeyId().isBlank() lets private_key_id ' ' be stored, and no test fails.); server/src/main/java/io/unitycatalog/server/persist/dao/CredentialDAO.java:502 (No test row has a null email. Removing the null check leaves the error to fromPkcs8, which throws an NPE that the catch block reports with the wrong 'not a PEM-); server/src/main/java/io/unitycatalog/server/persist/dao/CredentialDAO.java:508 (No test row has a blank (whitespace-only) private_key, only a null one. That case is caught only by the isBlank check, not by the parser branch.).

For example: Remove && !key.getPrivateKeyId().isBlank() and testGcpServiceAccountKeyCredential still passes. A request with private_key_id: " " and a valid key would then be stored.

new InvalidCreate(
    gcpRequest(privateKey).gcpServiceAccountKey(gcpKey(privateKey).privateKeyId(" ")),
    String.format(missing, "private_key_id")),
new InvalidCreate(gcpRequest(privateKey, null), String.format(missing, "email")),
Evidence

The validator checks null and blank for each field. The rows cover blank email (gcpRequest(privateKey, " ")), null private_key_id and null private_key only. No row has a blank private_key_id or a null email.

How it was checked

Checked by 1 independent check: CONFIRMED

Could these two rows go into the existing invalidCreates list?

* @return the write-only {@code private_key} of a {@code gcp_service_account_key} credential
*/
public String getGcpPrivateKey(CredentialSecretStore secretStore) {
JsonNode stored = readCredential(CredentialType.GCP_SERVICE_ACCOUNT_KEY).get(PRIVATE_KEY_FIELD);

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 (not a blocker): A damaged GCP credential row could produce an unnamed NPE at startup instead of naming the credential, and no test would notice

getGcpPrivateKey turns a missing or non-text private_key into an INTERNAL error that names the credential. The startup scan logs that error.

The S3 version of this branch has a test in testMissingStoredValueIsReportedByName. The GCP one does not. This is one bug class: A GCP read-back diagnostic copied from the S3 getter has no test of its own; only the S3 original is tested. The same issue appears in server/src/main/java/io/unitycatalog/server/persist/dao/CredentialDAO.java:566 (Removing the null and non-text check makes the code hit an NPE on stored.asText(), and the error loses the credential name. No test fails.); server/src/main/java/io/unitycatalog/server/persist/dao/CredentialDAO.java:548 (getGcpServiceAccountKeyResponse on a stored value that is not an object (the INTERNAL 'cannot be read' path) is tested only for S3_COMPATIBLE.).

For example: Delete the if (stored == null || !stored.isTextual()) block and every test still passes. A row without private_key would then fail with a NullPointerException that does not say which credential is damaged.

In CredentialDAOTest.testMissingStoredValueIsReportedByName, add a GCP DAO built with credentialType(GCP_SERVICE_ACCOUNT_KEY) and a stored blob of only email and private_key_id. Assert that getGcpPrivateKey(SECRET_STORE) throws BaseException with ErrorCode.INTERNAL and a message containing the credential name.

Evidence

The null/non-text check on the stored private_key raises INTERNAL with the name. The only test of this pattern, testMissingStoredValueIsReportedByName, builds an S3 DAO. No GCP DAO with a missing private_key appears in CredentialDAOTest or CredentialRepositoryTest.

How it was checked

Checked by 1 independent check: CONFIRMED

Would a GCP case beside the existing S3 one in that test be enough?

timothyw553 and others added 10 commits November 30, 2026 19:11
Storage credentials can now hold a Google Cloud service account key, so that
Unity Catalog can vend access to GCS (part of unitycatalog#47; vending follows).

- API: `gcp_service_account_key` (`email`, `private_key_id`, `private_key`) on
  `CreateCredentialRequest`; `CredentialInfo` returns the email and key id only
- `private_key` is validated as a PKCS#8 key and stored encrypted with the
  credential secret store from unitycatalog#2171; `server.credential-encryption-key` is now
  read whenever it is set, not only with S3-compatible storage enabled
- external locations of such a credential must be `gs://` paths, on create and
  update; a gcp_service_account_key credential cannot be changed to another type
- startup warns about a stored `private_key` the server cannot read
- schema step V4 adds the credential type on H2, MySQL and PostgreSQL
- CLI: `credential create --gcp_service_account_key_file <key.json>`

On MySQL the encrypted key does not fit the `credential` column until unitycatalog#2169
widens it; the CRUD test skips MySQL until then.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
…tial type, test the GCP scan, keep key file content out of CLI errors, document the PATCH restriction

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
…MySQL, schema test leaves later steps pending; say vending is not supported yet

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
…re stored as text

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
…t the encryption key for GCP, and say vending is not supported yet in the spec

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
…ace a failed temp key file delete in the CLI tests, and say in the cache Javadoc that GCP vending is not there yet

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
… version in the cache key, and fix two comments

The length tests rejected only values over the limit, so a check that was off by one would
still pass. Add an email and key id of exactly 1024 characters, which are accepted, and a
private key of exactly 4096 characters, which passes the length check and fails on its format.

The cache key held two version fields of which at most one was set. It holds one now, for
either an s3_compatible or a gcp_service_account_key credential.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
…ec, test a server with only GCP credentials, and cover both key types in the Helm docs

The spec did not show the 1024 and 4096 character limits the server enforces, nor that the
private key is write-only, so generated clients did not know either.

The Helm section on the credential encryption key was titled and written for s3_compatible
credentials only, though a gcp_service_account_key credential needs the same Secret and not
the S3 flag.

Add a test for a server that has the encryption key but leaves S3-compatible storage off,
which the credential CRUD tests do not cover since they turn it on.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
…mpatible as experimental, and explain why the cache key holds the GCP key's version

Google's JSON key file calls the email client_email, so the spec's "the fields of the
service account's JSON key file" would send someone who pastes the file to a missing-email
error. Say which field goes where, and that the server does not check the key with Google.

The gs:// rule of a gcp_service_account_key credential sat inside the EXPERIMENTAL paragraph
of s3_compatible on the external location endpoints. Only the s3:// rule is experimental.

The cache key Javadoc described the GCP key's id and fingerprint as for later, but they
already keep a token cached for the gcs.* settings from satisfying a stored-key request.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
@timothyw553
timothyw553 force-pushed the stack/gcp-credential-create branch from ec8cbdd to f4568b9 Compare November 30, 2026 19:14
@yili-db

yili-db commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

/review

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