Skip to content

Improve error message for S3 listObjects access denied errors - #103463

Merged
nickitat merged 4 commits into
masterfrom
improve_list_bucket_exc
Apr 28, 2026
Merged

nickitat merged 4 commits into
masterfrom
improve_list_bucket_exc

Conversation

@nickitat

@nickitat nickitat commented Apr 23, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Version info

  • Merged into: 26.5.1.139

nickitat and others added 3 commits April 23, 2026 19:03
When `S3ObjectStorage::listObjects` fails (e.g. `AccessDenied` on GCP/S3),
the exception now includes the bucket name, key prefix, and disk name so
users can immediately tell which path and disk caused the permission error.

Before: `Access denied. (Code: 15, S3 exception: 'AccessDenied')`
After:  `Access denied. (Code: 15, S3 exception: 'AccessDenied'),
         while listing objects in bucket 'my-bucket' with prefix 'data/' on disk 'gcp_disk'`

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Instead of wrapping `throwIfError` in a try/catch at call sites, add a
variadic overload that accepts a `fmt::format_string` context and appends
it to the exception message directly inside `throwIfError`. Update the
`listObjects` call to use the new overload, passing bucket, path prefix,
and disk name.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…perations

Four call sites where listing or existence-check operations could throw
with an opaque error message lacking disk/container/path info:

- `AzureObjectStorage::listObjects`: wrap `ListBlobs` loop in
  `try`/`catch (StorageException)`, re-throw as `DB::Exception` with
  container, prefix, and disk name.
- `AzureIteratorAsync::getBatchAndCheckNext`: same pattern for the async
  listing path; pass `container` and `disk_name` through the constructor
  so the catch block has full context.
- `AzureObjectStorage::exists`: the existing `StorageException` catch
  already handles `NotFound` correctly; now re-throws other errors
  (e.g. `AccessDenied`) as a `DB::Exception` with object path, container,
  and disk name instead of a bare `throw`.
- `S3ObjectStorage::getObjectMetadata`: the existing `addMessage` call
  only included the object path; extend it to also include the bucket
  and disk name.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [24b611e]

Summary: ✅


AI Review

Summary

This PR improves S3 object-storage exception context by appending bucket/prefix/disk information to listObjects failures and enriching getObjectMetadata errors with bucket and disk details. The change is focused, low-risk, and improves diagnosability without altering storage semantics.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Apr 23, 2026
@nickitat
nickitat marked this pull request as ready for review April 23, 2026 21:33
@kssenii kssenii self-assigned this Apr 27, 2026
@nickitat
nickitat force-pushed the improve_list_bucket_exc branch from de35bf0 to 24b611e Compare April 28, 2026 02:33
@nickitat
nickitat enabled auto-merge April 28, 2026 03:45
@clickhouse-gh

clickhouse-gh Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.00% 84.00% +0.00%
Functions 91.10% 91.10% +0.00%
Branches 76.50% 76.50% +0.00%

Changed lines: 100.00% (15/15) · Uncovered code

Full report · Diff report

@nickitat
nickitat added this pull request to the merge queue Apr 28, 2026
Merged via the queue into master with commit 63b2100 Apr 28, 2026
325 of 326 checks passed
@nickitat
nickitat deleted the improve_list_bucket_exc branch April 28, 2026 07:39
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants