Repository navigation
Report missing AWS credentials as an error, not a panic; lint against unwrap() - #45
Merged
Merged
Conversation
…ainst unwrap() get_aws_config() panicked when no AWS credentials could be found, printing a Debug dump and exiting 101. It now returns an ExpectedError naming each provider that was tried and why it failed, and exits 1. Enable clippy::unwrap_used (allowed in tests), so CI rejects new unwrap()s in production code, and replace the four in main.rs's tracing setup.
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.
Running
bergr glue,bergr from s3://…orbergr rest --auth sigv4without usable AWS credentials no longer panics. It now prints an error naming each credential provider that was tried and why it failed, and exits 1:Before, it panicked in
get_aws_config(), dumpedCredentialsNotLoaded(CredentialsNotLoaded { source: Some(ProviderChainError { … }) })and exited 101.The PR also enables
clippy::unwrap_used, withallow-unwrap-in-tests. CI already runs clippy with-D warnings, so newunwrap()s in production code will fail the build. The only existing ones were fourparse().unwrap()s on hard-coded tracing directives inmain.rs. These now go through a singleexpectthat states the invariant.Changes
src/aws.rs:get_aws_config()returnsResult. The check moves intocheck_credentials(), which returns anExpectedError. The source chain is formatted with anyhow's{:#}, which shows each cause without aDebugdump.src/main.rs: the callers propagate the error with?. The--debugtracing targets are now aDEBUG_TARGETSlist, folded into theEnvFilter.Cargo.tomlandclippy.toml: turn on the lint, allowing it in tests.Testing
cargo fmt,cargo clippy --all-targets -- -D warningsandcargo test(61 tests) pass. The new tests cover a provider that fails and one that works.AWS_PROFILE, and with a working profile against a real Glue catalog. The--debugoutput matchesmain's.