fix: validate s3 sync settings and explain s3 errors - #57
Open
sudores wants to merge 1 commit into
Open
Conversation
S3 answers a mistyped key, a newline picked up while pasting and a misspelled region with the same opaque SignatureDoesNotMatch, so the settings form gave no way to tell a wrong credential from a wrong region. Validate the fields that can be checked without talking to the server, in the settings view model and again in sync_aws so credentials that never went through the screen are covered too. Checks that only hold for real AWS (key shapes, region names) are skipped when a custom endpoint is set, since minio, Garage and the other S3-compatible services pick their own. Turn the S3 error codes users actually hit into an explanation of what to check, keeping the original message for reference. Stop the keyboard from rewriting credentials: auto-correction, word suggestions and automatic capitalization all alter what was typed, and the result is only reported as an authentication failure. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #51
Problem
S3 answers a mistyped key, a newline picked up while pasting and a misspelled region with the same opaque
SignatureDoesNotMatch, so there was no way for a user to tell a wrong credential from a wrong region — which is exactly where #51 stalled.Changes
SettingsViewModeland again insync_aws, so credentials that never went through the settings screen are covered too. Checks that only hold for real AWS (key shapes, region names) are skipped when a custom endpoint is set, since minio, Garage, R2 and the rest pick their own.SignatureDoesNotMatch,NoSuchBucket,AccessDenied,PermanentRedirect/AuthorizationHeaderMalformed,RequestTimeTooSkewed), keeping the original message for reference.singleLinewith capitalization and autocorrect off.Verification
The existing integration test only covered path-style with an endpoint URL. Real AWS takes a different path — no endpoint means
force_path_style: false, virtual-hosted addressing, and the region participating in the SigV4 signature — which was untested.I exercised that path by pointing
AWS_ENDPOINT_URL_S3(honored by taskchampion viaaws_config::defaults()) at a minio configured withMINIO_DOMAIN+ wildcard DNS andregion=eu-west-2, using AWS-shaped credentials. The client code path is then identical to real AWS, against a server that enforces the region.garage)AuthorizationHeaderMalformed→ "The bucket lives in a different region than the one configured…"SignatureDoesNotMatch→ "S3 rejected the request signature. The access key ID and secret access key must be copied exactly…"No false rejections across 12 real provider config shapes — AWS (eu-west-2, no region, GovCloud, China, dotted bucket), minio, Cloudflare R2 (region
auto, 32/64-hex creds), Backblaze B2, Wasabi, DigitalOcean Spaces, Garage, and a generic short-credential service. 7 malformed configs are each rejected with a message naming the field. The Rust and Kotlin validators produce identical verdicts and messages across the whole matrix.cargo test --lib(29 passed),cargo clippy --all-targets -D warningsandcargo fmt --checkare clean; the S3 integration test passes against the compose minio.Known gaps, not addressed here
unhandled error:taskchampion::Error::Otheris#[error(transparent)]over anyhow, and only aws-sdk'sUnhandledvariant appends a code, so thedispatch failure/error trying to connectbranches never match. Wants a catch-all or walkingsource().https://s3.eu-west-2.amazonaws.com) bypasses the AWS key/region checks and switches to path-style addressing.us-east-1bucket would be refused.sync.aws.*keys from S3 sync, SignatureDoesNotMatch #51 are untouched — that is taskrc import should import the storage settings #52.Caveat
This was not tested against real AWS S3 (no account available). What is verified is the identical client code path against a region-enforcing S3 server, which covers the addressing and signing behaviour but not AWS-specific server quirks.
🤖 Generated with Claude Code