Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add safe dictionary access for bedrock credentials #11860

Merged
merged 4 commits into from
Dec 20, 2024

Conversation

KMerdan
Copy link
Contributor

@KMerdan KMerdan commented Dec 19, 2024

Summary

This PR enhances error handling as discussed in Issue #11819 by implementing safe dictionary access for AWS credentials. Previously, the code relied on direct dictionary access, which risked KeyError exceptions if aws_region was missing in the provided credentials.

Changes made:

  • Replace direct dictionary access with .get() method for aws_region
  • Add validation check to ensure aws_region is provided
  • Raise InvokeBadRequestError with a clear error message if the required credential is missing

This change makes the code more robust and provides better error handling for missing AWS region configuration.

Checklist

  • This change requires a documentation update
  • I understand that this PR may be closed in case there was no previous discussion or issues
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change
  • I've updated the documentation accordingly
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@KMerdan KMerdan marked this pull request as ready for review December 20, 2024 00:03
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working labels Dec 20, 2024
Copy link
Member

@laipz8200 laipz8200 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 20, 2024
@KMerdan KMerdan merged commit bb2f46d into main Dec 20, 2024
8 checks passed
@KMerdan KMerdan deleted the fix/aws_blank_AKSK branch December 20, 2024 03:13
jiangbo721 pushed a commit to jiangbo721/dify that referenced this pull request Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants