Skip to content

Commit f65672c

Browse files
author
Bob Strahan
committed
Merge branch 'develop' into feature/idp-cli-doc-status
2 parents c610834 + 89ad536 commit f65672c

File tree

3 files changed

+73
-7
lines changed

3 files changed

+73
-7
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ SPDX-License-Identifier: MIT-0
3434
- JSON format output (`--format json`) provides structured data for parsing in CI/CD pipelines and scripts
3535
- Live monitoring support with `--wait` flag works for both batch and single document status checks
3636
- Mutual exclusion validation ensures only one of `--batch-id` or `--document-id` is specified
37+
- **Error Analyzer CloudWatch Tool Enhancements**
38+
- Enhanced CloudWatch log filtering with request ID-based filtering for more targeted error analysis
39+
- Improved XRay tool tracing and logging capabilities for better diagnostic accuracy
40+
- Enhanced error context correlation between CloudWatch logs and X-Ray traces
41+
- Consolidated and renamed tools
42+
- Provided tools access to agent
43+
- Updated system prompt
44+
45+
- **Error Analyzer CloudWatch Tool Enhancements**
46+
- Enhanced CloudWatch log filtering with request ID-based filtering for more targeted error analysis
47+
- Improved XRay tool tracing and logging capabilities for better diagnostic accuracy
48+
- Enhanced error context correlation between CloudWatch logs and X-Ray traces
49+
- Consolidated and renamed tools
50+
- Provided tools access to agent
51+
- Updated system prompt
3752

3853

3954
### Fixed
@@ -45,6 +60,7 @@ SPDX-License-Identifier: MIT-0
4560
- **Enhanced Debugging**: Added detailed console logging with full PK/SK information for both list entries and expected document entries to facilitate cleanup of orphaned records
4661
- **User Impact**: All valid documents now display correctly even when orphaned list entries exist; debugging information available in browser console for identifying problematic entries
4762

63+
4864
## [0.3.21]
4965

5066
### Added

lib/idp_common_pkg/idp_common/assessment/service.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,22 @@ def __init__(
9393
region: AWS region for Bedrock
9494
config: Configuration dictionary or IDPConfig model
9595
"""
96-
# Convert dict to IDPConfig if needed
97-
if config is not None and isinstance(config, dict):
98-
config_model: IDPConfig = IDPConfig(**config)
99-
100-
if not isinstance(config, IDPConfig) and config is not None:
101-
config_model = IDPConfig(**config)
102-
96+
# Convert config to IDPConfig if needed
10397
if config is None:
10498
config_model = IDPConfig()
99+
elif isinstance(config, IDPConfig):
100+
config_model = config
101+
elif isinstance(config, dict):
102+
config_model = IDPConfig(**config)
103+
else:
104+
# Fallback: attempt conversion for other types
105+
try:
106+
config_model = IDPConfig(**config)
107+
except Exception as e:
108+
logger.error(f"Failed to convert config to IDPConfig: {e}")
109+
raise ValueError(
110+
f"Invalid config type: {type(config)}. Expected None, dict, or IDPConfig instance."
111+
)
105112

106113
self.config = config_model
107114
self.region = region or os.environ.get("AWS_REGION")

lib/idp_common_pkg/tests/unit/assessment/test_assessment_service.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
# Finally import application modules
2525
from idp_common.assessment.service import AssessmentService
26+
from idp_common.config.models import IDPConfig
2627
from idp_common.models import Document, Section, Status, Page
2728

2829

@@ -482,3 +483,45 @@ def test_process_document_section_empty_extraction_results(
482483
# Should return without error but log warning
483484
assert len(result.errors) == 0
484485
mock_get_json_content.assert_called_once()
486+
487+
def test_init_with_none_config(self):
488+
"""Test initialization with None config creates default IDPConfig."""
489+
service = AssessmentService(region="us-east-1", config=None)
490+
491+
assert service.region == "us-east-1"
492+
assert isinstance(service.config, IDPConfig)
493+
# Verify default config has assessment settings
494+
assert hasattr(service.config, "assessment")
495+
496+
def test_init_with_dict_config(self, mock_config):
497+
"""Test initialization with dict config converts to IDPConfig."""
498+
service = AssessmentService(region="us-east-1", config=mock_config)
499+
500+
assert service.region == "us-east-1"
501+
assert isinstance(service.config, IDPConfig)
502+
# Verify config was properly converted
503+
assert service.config.assessment.model == mock_config["assessment"]["model"]
504+
505+
def test_init_with_idpconfig_instance(self, mock_config):
506+
"""Test initialization with IDPConfig instance (the previously failing case)."""
507+
# Create an IDPConfig instance first
508+
config_instance = IDPConfig(**mock_config)
509+
510+
# Initialize service with IDPConfig instance
511+
service = AssessmentService(region="us-east-1", config=config_instance)
512+
513+
assert service.region == "us-east-1"
514+
assert isinstance(service.config, IDPConfig)
515+
# Should use the same instance
516+
assert service.config is config_instance
517+
# Verify config properties are accessible
518+
assert service.config.assessment.model == mock_config["assessment"]["model"]
519+
520+
def test_init_with_invalid_config_type(self):
521+
"""Test initialization with invalid config type raises ValueError."""
522+
# Try to initialize with an invalid config type (e.g., a string)
523+
with pytest.raises(ValueError) as exc_info:
524+
AssessmentService(region="us-east-1", config="invalid_config")
525+
526+
# Verify error message mentions the invalid type
527+
assert "Invalid config type" in str(exc_info.value)

0 commit comments

Comments
 (0)