Repository navigation
Conversation
Add `BackupInfo::toNormalizedString`, which produces a deterministic identity string for a backup destination. `S3` identities are built from parsed URI fields, `AzureBlobStorage` connection strings are normalized per component, and `Disk` and `File` destinations normalize paths. Credential-only arguments and credential key-value overrides are excluded from the identity. Add `BackupInfo::freezeNamedCollection` to materialize named collection arguments so the identity stays stable if the collection changes later. This is infrastructure for resumable `BACKUP FROM SNAPSHOT`; it adds no callers and does not change backup behavior.
|
Workflow [PR], commit [66f12f2] Summary: ❌
AI ReviewSummaryThis PR adds normalized, credential-free backup-destination identities plus named-collection freezing for future resumable snapshot work. Most of the earlier destination-alignment problems have been fixed, but one credential-redaction invariant is still inconsistent with the new logic: case-insensitive or ignored S3 override spellings are stripped from Findings❌ Blockers
Final Verdict
|
There was a problem hiding this comment.
Pull request overview
Adds infrastructure to compute a deterministic, credential-free “normalized identity” string for backup destinations (BackupInfo::toNormalizedString), including optional resolution of named collections (and a way to freeze them) to support future deterministic/resumable BACKUP FROM SNAPSHOT identity.
Changes:
- Added
BackupInfo::toNormalizedString(with and withoutContextPtr) plus normalization helpers for S3/Azure/Disk/File destinations. - Added
BackupInfo::freezeNamedCollectionand afrozen_named_collectionfield to allow resolving named collections once and reusing the resolved collection. - Expanded
gtest_backup_infocoverage for normalization behavior (credential elision/redaction, canonicalization, context validation).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/Backups/BackupInfo.h |
Extends BackupInfo API with normalized identity methods and named-collection freezing support. |
src/Backups/BackupInfo.cpp |
Implements normalization logic for backup destinations, including optional context-based validation and named-collection resolution. |
src/Backups/tests/gtest_backup_info.cpp |
Adds gtest coverage for normalized identity determinism, credential redaction, and context-dependent validation. |
Strip arbitrary query parameters from direct `S3` backup URLs before parsing the destination identity, while preserving `versionId`. This keeps non-presigned query parameters out of the normalized identity and fixes the Fast test build where the fragment helper was unused without `USE_AWS_S3`.
Apply the same query normalization to `S3` named-collection paths as direct `S3` URLs. Only `versionId` affects the normalized identity; arbitrary query parameters are ignored so they cannot leak into the identity string.
Use `std::filesystem::path` joining when resolving `S3` named-collection paths, matching `registerBackupEngineS3`. This keeps normalized backup identity aligned with the effective destination opened by the backup engine.
Move `File` and `Disk` backup destination validation into shared helpers used by both `registerBackupEnginesFileAndDisk` and `BackupInfo::toNormalizedString`. This keeps normalized backup identity validation aligned with the destination validation performed by the backup engines.
Let `S3::URI` decide whether query parameters are part of the object key instead of stripping every non-`versionId` parameter first. This keeps non-presigned plain query parameters destination-significant while still omitting presigned credential parameters from the parsed identity.
Use exact override key names when building the no-context normalized identity for named-collection backups. This keeps `URL` distinct from `url`, matching the backup engines where overrides are consumed by exact lowercase names.
|
Updating the branch to fix the |
Reject invalid `S3`, `AzureBlobStorage`, `File`, and `Disk` locator shapes before building a normalized backup identity. Also validate skipped credential arguments and direct `S3` `extra_credentials`, so invalid locators cannot alias accepted destinations.
Stop `stripURLUserInfo` at query and fragment boundaries as well as paths. This avoids treating `@` inside a query string as userinfo when normalizing credential-free `S3` backup identities.
Clear ignored function arguments after resolving named-collection backup destinations, so the normalized identity validation continues to match the backup engines. Direct `S3` `extra_credentials` are still validated before normalization.
The Fast test build disables `USE_AWS_S3`, so the validation helper does not need the `ContextPtr` parameter in that configuration. Mark it as `[[maybe_unused]]` to keep the `S3`-enabled validation path unchanged while avoiding `-Wunused-parameter`.
Correct the argument-count diagnostic for `AzureBlobStorage` normalized backup identity validation so it shows the intended `connection string/url` syntax.
Resolve backup named collections through `tryGetNamedCollectionWithOverrides` so normalized backup identity uses the same `isOverridable` and `allow_named_collection_override_by_default` checks as backup engine resolution. Add a regression test for rejecting a non-overridable `url` override.
| if (s.find(';') == String::npos) | ||
| return stripOneTrailingSlash(stripURLUserInfo(stripURLQuery(s))); |
There was a problem hiding this comment.
Dismissed: uppercase-scheme URLs are not equivalent in the live generic Azure path. AzureBlobStorage::processURL uses the case-sensitive !candidate.starts_with("http") test, so HTTPS://... is treated as a connection string and rejected. The valid explicit-credential path is canonicalized by normalizePlainAzureStorageAccountURL before reaching this fallback. Changing the fallback would make normalization accept a locator the live engine rejects, so I am leaving this thread unresolved.
| #if USE_AZURE_BLOB_STORAGE | ||
| if (!s.starts_with("http")) | ||
| { |
There was a problem hiding this comment.
Dismissed for the same runtime-contract reason: normalizeAzureConnection intentionally mirrors the live 3-argument processURL classifier, which is case-sensitive and treats HTTPS://... as a connection string. Five-argument explicit-credential URLs are validated and canonicalized to lowercase before this function. Making this check case-insensitive would alias an invalid live locator with a valid one. Leaving unresolved.
Convert Poco and Azure URL parser failures into `BAD_ARGUMENTS` without empty catch blocks. Keep shape validation outside parser catches so its specific diagnostics are preserved.
Fail closed when generic Azure URLs or parsed connection-string endpoints retain fragments that the live engine keeps in the endpoint. Continue ignoring fragment characters that occur only inside SAS query credentials.
Require context or a frozen collection before accepting Azure connection overrides whose precedence and credential mode depend on stored state. Report malformed override structure without formatting literal values.
Replace invalid `extra_credentials` details with structure-only diagnostics, including validation exceptions and malformed placement. This preserves useful function shape without exposing literal values.
Wrap normalized S3 URL and path parsing with credential-free `BAD_ARGUMENTS` diagnostics. Successful parsing retains full `S3::URI` semantics, including version identifiers.
| S3::URI parseS3URIForNormalizedIdentity(const String & uri, std::string_view argument_description) | ||
| { | ||
| try | ||
| { | ||
| return S3::URI(uri, /* allow_archive_path_syntax = */ false); | ||
| } | ||
| catch (const Poco::Exception &) | ||
| { | ||
| throw Exception( | ||
| ErrorCodes::BAD_ARGUMENTS, | ||
| "Failed to parse S3 {} for normalized backup identity", | ||
| argument_description); | ||
| } | ||
| } |
There was a problem hiding this comment.
Dismissed: DB::Exception is declared as class Exception : public Poco::Exception in src/Common/Exception.h, so this catch already sanitizes both DB::Exception from S3::URI::validateKey and Poco URI parser failures. The tests explicitly exercise both paths (double-slash DB validation and malformed-percent Poco syntax) and verify the presigned secret is absent. Query parameters cannot be dropped before parsing because versionId is destination-significant. Leaving unresolved.
| { | ||
| auto base = BackupInfo::fromString("S3(collection)"); | ||
| auto with_credentials = BackupInfo::fromString( | ||
| "S3(collection, ACCESS_KEY_ID='KEYID', google_adc_client_id='CLIENTID', google_adc_client_secret='CLIENTSECRET', " |
There was a problem hiding this comment.
toNormalizedString now treats credential-like override keys case-insensitively, but BackupImpl still serializes <base_backup> through BackupInfo::withoutS3Credentials, and that helper only strips exact lowercase spellings in src/Backups/BackupInfo.cpp:1088-1104. As a result, the shape introduced in this test still leaks into metadata: S3(collection, ACCESS_KEY_ID='KEYID') keeps KEYID in .backup, and the same exact-case gap leaves ignored URL= overrides able to persist presigned or userinfo credentials. Please share the same case-insensitive key handling with withoutS3Credentials before relying on these redaction invariants.
|
Superseded by #110610, which moves destination identity into engine-owned |
Adds
BackupInfo::toNormalizedStringandBackupInfo::freezeNamedCollection.The normalized string is a deterministic, credential-free identity for a backup
destination. It normalizes
S3,AzureBlobStorage,Disk, andFilebackupdestinations, excludes credential-only positional arguments and credential-only
key-value overrides, includes non-credential named-collection overrides that can
change the destination, and can resolve named collections with a
Contextwhenneeded.
This is infrastructure for deterministic resumable
BACKUP FROM SNAPSHOTidentity in follow-up changes. There are no callers yet, so this PR does not
change user-visible backup behavior.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not for changelog.