This is an automated email from the ASF dual-hosted git repository. github-actions[bot] pushed a commit to branch cherry-pick-e7fee431-to-branch-1.3 in repository https://gitbox.apache.org/repos/asf/gravitino.git
commit 396e92702ab6548e31054c4c53379b89e1b9b373 Author: MaSai <[email protected]> AuthorDate: Thu Sep 10 09:03:35 2026 +0800 [#13033] fix(iceberg): Map PostgreSQL JDBC auth failures to ConnectionFailedException (#13034) ### What changes were proposed in this pull request? Classify Iceberg JDBC catalog authorization failures via SQLState class `28` (plus MySQL/PostgreSQL message fallbacks), so PostgreSQL bad-credential errors become `ConnectionFailedException` like MySQL `Access denied`. ### Why are the changes needed? Previously only the literal `Access denied` was matched. PostgreSQL reports `password authentication failed` / `role ... does not exist` (`28P01` / `28000`), so failures escaped as raw `UncheckedSQLException`. Fix: #13033 ### Does this PR introduce _any_ user-facing change? - PostgreSQL Iceberg JDBC catalogs with bad credentials now surface `ConnectionFailedException` instead of a generic internal error. - No new APIs or property keys. ### How was this patch tested? ``` ./gradlew :iceberg:iceberg-common:test --tests org.apache.gravitino.iceberg.common.utils.TestIcebergCatalogUtil -PskipITs ``` --------- Co-authored-by: Cursor <[email protected]> # Conflicts: # iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergCatalogUtil.java --- .../iceberg/common/utils/IcebergCatalogUtil.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergCatalogUtil.java b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergCatalogUtil.java index f849b77ad5..068f4c786a 100644 --- a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergCatalogUtil.java +++ b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergCatalogUtil.java @@ -58,6 +58,27 @@ public class IcebergCatalogUtil { private static final Logger LOG = LoggerFactory.getLogger(IcebergCatalogUtil.class); +<<<<<<< HEAD +======= + /** + * Column that Iceberg adds to the {@code iceberg_tables} control table in its V1 view-support + * migration (see {@code JdbcUtil} in iceberg-core). + */ + private static final String ICEBERG_TYPE_COLUMN = "iceberg_type"; + + /** + * SQLSTATE {@code 28000}: MySQL error 1045 (Access denied), H2 wrong user/password, and + * PostgreSQL {@code invalid_authorization_specification} (for example unknown role). + */ + private static final String SQLSTATE_INVALID_AUTHORIZATION = "28000"; + + /** SQLSTATE {@code 28P01}: PostgreSQL {@code invalid_password}. */ + private static final String SQLSTATE_INVALID_PASSWORD = "28P01"; + + private static final String GCS_CLOUD_PLATFORM_SCOPE = + "https://www.googleapis.com/auth/cloud-platform"; + +>>>>>>> e7fee4319 ([#13033] fix(iceberg): Map PostgreSQL JDBC auth failures to ConnectionFailedException (#13034)) private static final ConcurrentHashMap<String, InMemoryCatalog> MEMORY_CATALOGS = new ConcurrentHashMap<>(); @@ -170,9 +191,19 @@ public class IcebergCatalogUtil { try { jdbcCatalog.initialize(icebergCatalogName, properties); } catch (UncheckedSQLException e) { +<<<<<<< HEAD if (e.getCause() instanceof SQLException && e.getCause().getMessage().contains("Access denied")) { throw new ConnectionFailedException(e, e.getMessage()); +======= + Throwable cause = e.getCause(); + if (cause instanceof SQLException) { + String sqlState = ((SQLException) cause).getSQLState(); + if (SQLSTATE_INVALID_AUTHORIZATION.equals(sqlState) + || SQLSTATE_INVALID_PASSWORD.equals(sqlState)) { + throw new ConnectionFailedException(e, e.getMessage()); + } +>>>>>>> e7fee4319 ([#13033] fix(iceberg): Map PostgreSQL JDBC auth failures to ConnectionFailedException (#13034)) } throw e; }
