Skip to content

fix: bedroc profile creation fix#495

Merged
DoganK01 merged 2 commits intomasterfrom
bedrock-profile-fix
Dec 12, 2025
Merged

fix: bedroc profile creation fix#495
DoganK01 merged 2 commits intomasterfrom
bedrock-profile-fix

Conversation

@DoganK01
Copy link
Copy Markdown
Member

  • Bedrock API profile fix

@claude
Copy link
Copy Markdown

claude bot commented Dec 12, 2025

Pull Request Review: Bedrock Profile Creation Fix

I've reviewed PR #495 and identified several critical issues that should be addressed before merging.

Critical Issues

1. Silent Model Switching (High Priority)
Location: bedrock.py:625
The code silently switches from Claude to Amazon Titan without logging or user notification. This is a production reliability risk as users may be unaware they're using a different model with different capabilities and costs.

Recommendation: Add logging.warning() to notify users when fallback occurs.

2. Hardcoded AWS Credentials (Security Risk)
Location: bedrock.py:275-280
Creating a new boto3.Session with hardcoded environment variables bypasses the existing client credentials and doesn't respect IAM roles or instance profiles.

Recommendation: Reuse credentials from the existing self.client instead of creating a parallel credential path.

3. Overly Broad Exception Handling
Location: Lines 330, 374
Using bare 'except Exception' swallows all errors including programming bugs, making debugging impossible.

Recommendation: Use specific exceptions like (ClientError, AttributeError, KeyError, TypeError).

Bugs

  1. Unreachable return statement at line 334
  2. Race condition possible when multiple requests try to create the same profile simultaneously
  3. Type annotation uses Any instead of specific type
  4. Unused region parameter in _create_inference_profile_for_model
  5. String truncation logic may truncate model ID unexpectedly

Missing Test Coverage

This PR adds 181 lines of complex error handling but includes NO tests. Need tests for:

  • Inference profile auto-discovery
  • Inference profile creation
  • Fallback to Titan model
  • Permission errors
  • Missing boto3 handling

Recommendations Before Merge

  1. Add logging for model fallback
  2. Fix credential handling
  3. Add specific exception types
  4. Add comprehensive unit tests
  5. Add docstrings explaining AWS permissions required
  6. Remove unreachable code
  7. Consider making auto-fallback opt-in via configuration flag

Positive Aspects

  • Good error message for users
  • Backward compatible
  • Handles missing boto3 gracefully
  • Attempts graceful degradation

Overall: The PR addresses a real pain point but needs hardening in error handling, security, testing, and user communication before production use.

Happy to help implement these suggestions!

@DoganK01 DoganK01 merged commit a45988d into master Dec 12, 2025
4 checks passed
@DoganK01 DoganK01 deleted the bedrock-profile-fix branch December 12, 2025 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant