fix: use self.comprehend_client consistently in ComprehendFilterAgent#427
Open
themavik wants to merge 1 commit intoawslabs:mainfrom
Open
fix: use self.comprehend_client consistently in ComprehendFilterAgent#427themavik wants to merge 1 commit intoawslabs:mainfrom
self.comprehend_client consistently in ComprehendFilterAgent#427themavik wants to merge 1 commit intoawslabs:mainfrom
Conversation
When `options.client` is None, the `__init__` method was incorrectly assigning the boto3 client to `self.client` instead of `self.comprehend_client`. All downstream methods (`detect_sentiment`, `detect_pii_entities`, `detect_toxic_content`) reference `self.comprehend_client`, causing an `AttributeError` at runtime. Changed both `else` branches to assign to `self.comprehend_client` so the attribute name is consistent regardless of whether a custom client is provided or one is created internally. Fixes awslabs#359
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.
Summary
ComprehendFilterAgentraisesAttributeError: 'ComprehendFilterAgent' object has no attribute 'comprehend_client'when instantiated without providing a customclientin options.Root Cause
In
__init__, whenoptions.clientisNone, the boto3 Comprehend client is assigned toself.clientinstead ofself.comprehend_client:All downstream methods (
detect_sentiment,detect_pii_entities,detect_toxic_content) referenceself.comprehend_client, so any agent created without a pre-built client immediately fails.Fix
Changed both
elsebranches to assign toself.comprehend_client:Test Plan
ComprehendFilterAgentwithclient=Noneand aregion— no longer raisesAttributeErrorclient=Noneand noregion— uses default boto3 region, no errorclient— behavior unchangedFixes #359