Skip to content

Kafka Connect: Handle AccessDeniedException in auto-create (#13758)#16072

Open
yadavay-amzn wants to merge 1 commit intoapache:mainfrom
yadavay-amzn:fix/13758-access-denied-autocreate
Open

Kafka Connect: Handle AccessDeniedException in auto-create (#13758)#16072
yadavay-amzn wants to merge 1 commit intoapache:mainfrom
yadavay-amzn:fix/13758-access-denied-autocreate

Conversation

@yadavay-amzn
Copy link
Copy Markdown
Contributor

Summary

Fixes #13758.

When iceberg.tables.auto-create-enabled is set, the Kafka Connect sink connector calls GlueCatalog.createNamespace() which can throw software.amazon.awssdk.services.glue.model.AccessDeniedException if the user lacks glue:CreateDatabase permission. This exception was not caught, crashing the connector even when the database already exists.

Changes

Root cause fix — GlueCatalog.createNamespace():

  • Catch AccessDeniedException and wrap it as Iceberg's ForbiddenException, consistent with how GlueTableOperations already handles this exception for table operations.

Defense-in-depth — IcebergWriterFactory.createNamespaceIfNotExist():

  • Add NotAuthorizedException to the existing catch block alongside AlreadyExistsException and ForbiddenException, so auth exceptions from any catalog implementation are handled gracefully.

Testing

  • Added testCreateNamespaceAccessDenied in TestGlueCatalog — verifies AccessDeniedException is wrapped as ForbiddenException.
  • Added testCreateNamespaceHandlesForbiddenException and testCreateNamespaceHandlesNotAuthorizedException in TestIcebergWriterFactory — verifies both exception types are swallowed during namespace creation.

)

GlueCatalog.createNamespace() did not catch AccessDeniedException from
the AWS Glue SDK. When a user lacks glue:CreateDatabase permission, Glue
throws AccessDeniedException (HTTP 400) which propagated uncaught,
crashing the Kafka Connect connector even when the database already
exists.

This fix:
- Catches AccessDeniedException in GlueCatalog.createNamespace() and
  wraps it as ForbiddenException, consistent with how
  GlueTableOperations already handles this exception.
- Adds NotAuthorizedException to the catch block in
  IcebergWriterFactory.createNamespaceIfNotExist() for defense-in-depth
  against auth exceptions from any catalog implementation.

Closes apache#13758
@yadavay-amzn yadavay-amzn force-pushed the fix/13758-access-denied-autocreate branch from eac974f to 4a1977d Compare April 21, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow AccessDeniedExceptions To Fail Silently On Auto Creating Tables

1 participant