Skip to content

Commit 0993b6f

Browse files
committed
feat: Enhanced exception handling, automatic initialization, and dynamic locale detection
Major improvements to developer experience and Lambda function simplification: ## Enhanced Exception Handling - Enhanced handle_exceptions function with optional custom error messages - Support for both message keys and direct strings in error handling - Automatic localization fallback when message keys are not found - Comprehensive unit tests for exception handling scenarios ## Automatic Message Manager Initialization - Added auto_initialize_messages configuration option to Config class - Automatic MessageManager initialization with locale from Lex request - Eliminates need for manual initialize_message_manager() calls - Graceful error handling for MessageManager initialization failures ## Automatic Exception Handling in Lambda Functions - Added auto_handle_exceptions configuration option to Config class - Automatic exception handling and error response generation - Custom error message configuration via error_message parameter - Eliminates need for try/catch blocks in Lambda functions - Reduces Lambda function boilerplate by ~50% ## Message Consistency Testing Framework - Comprehensive test suite for message key consistency across locales - Validates all YAML message files have identical keys - Parameter consistency validation for message templates - Placeholder detection to prevent incomplete translations - Required message category validation ## Dynamic Locale Detection in CDK - Automatic locale detection based on Lex bot export structure - Dynamic generation of bot locale configurations - Eliminates hardcoded locale lists in CDK stack - Reads confidence thresholds from BotLocale.json files ## Enhanced Deployment Scripts - Improved deployment script with better error handling - Automatic cleanup of old wheel files to prevent hash conflicts - Targeted uv cache cleaning for specific packages - Lock file regeneration to avoid dependency conflicts ## Developer Experience Improvements - Simplified Lambda function structure with automatic handling - Enhanced Config class with new configuration options - Maintains backward compatibility with existing configurations - Comprehensive test coverage for all new features
1 parent 21ffe36 commit 0993b6f

15 files changed

Lines changed: 1493 additions & 155 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ repos:
3030

3131
# Pyright for type checking
3232
- repo: https://github.com/RobertCraigie/pyright-python
33-
rev: v1.1.390
33+
rev: v1.1.405
3434
hooks:
3535
- id: pyright
3636
description: Run pyright type checker

CHANGELOG.md

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,49 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased] - 0.0.2
99

10+
### Added
11+
12+
- **Enhanced Exception Handling**
13+
- Enhanced `handle_exceptions` function with optional custom error messages
14+
- Support for both message keys and direct strings in error handling
15+
- Automatic localization fallback when message keys are not found
16+
- Comprehensive unit tests for exception handling scenarios
17+
18+
- **Automatic Message Manager Initialization**
19+
- Added `auto_initialize_messages` configuration option to Config class
20+
- Automatic MessageManager initialization with locale from Lex request
21+
- Eliminates need for manual `initialize_message_manager()` calls in Lambda functions
22+
- Graceful error handling for MessageManager initialization failures
23+
24+
- **Automatic Exception Handling in Lambda Functions**
25+
- Added `auto_handle_exceptions` configuration option to Config class
26+
- Automatic exception handling and error response generation
27+
- Custom error message configuration via `error_message` parameter
28+
- Eliminates need for try/catch blocks in Lambda functions
29+
- Maintains proper Lex response formatting for all error scenarios
30+
31+
- **Message Consistency Testing Framework**
32+
- Comprehensive test suite for message key consistency across locales
33+
- Validates all YAML message files have identical keys
34+
- Parameter consistency validation for message templates
35+
- Placeholder detection to prevent incomplete translations
36+
- Required message category validation
37+
- Integration with existing test infrastructure
38+
39+
- **Dynamic Locale Detection in CDK**
40+
- Automatic locale detection based on Lex bot export structure
41+
- Dynamic generation of bot locale configurations
42+
- Eliminates hardcoded locale lists in CDK stack
43+
- Reads confidence thresholds from BotLocale.json files
44+
- Automatic fallback to en_US if no locales detected
45+
46+
- **Enhanced Deployment Scripts**
47+
- Improved deployment script with better error handling
48+
- Automatic cleanup of old wheel files to prevent hash conflicts
49+
- Targeted uv cache cleaning for specific packages
50+
- Lock file regeneration to avoid dependency conflicts
51+
- Validation of required tools and directory structure
52+
1053
### Changed
1154

1255
- **Dependency Management Migration**
@@ -16,12 +59,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1659
- Updated CDK bundling configuration to automatically detect and use uv for Lambda packaging
1760
- Modified deployment scripts to use `uv sync` instead of `poetry lock`
1861

62+
- **Simplified Lambda Function Structure**
63+
- Reduced Lambda function boilerplate by ~50% through automatic handling
64+
- Eliminated manual MessageManager initialization calls
65+
- Removed manual exception handling try/catch blocks
66+
- Streamlined configuration through enhanced Config class
67+
68+
- **Enhanced Config Class**
69+
- Added `auto_initialize_messages` (default: True)
70+
- Added `auto_handle_exceptions` (default: True)
71+
- Added `error_message` for custom error message configuration
72+
- Maintains backward compatibility with existing configurations
73+
74+
### Fixed
75+
76+
- **Exception Handling Improvements**
77+
- Fixed SessionState validation errors in error responses
78+
- Improved error message localization with proper fallbacks
79+
- Enhanced error response formatting for all channels
80+
81+
- **Deployment Reliability**
82+
- Fixed hash mismatch issues in uv dependency resolution
83+
- Improved wheel file management in deployment pipeline
84+
- Enhanced error handling in deployment scripts
85+
1986
### Technical Details
2087

2188
- Changed build system from `poetry-core` to `hatchling` for better PEP 621 compatibility
2289
- Updated Python version constraints to be compatible with all dependencies (`>=3.12,<4.0`)
2390
- Configured CDK `PythonFunction` and `PythonLayerVersion` to properly detect uv configuration
24-
- Maintained all existing functionality while improving build performance
91+
- Added comprehensive test coverage for new exception handling features
92+
- Implemented dynamic locale detection using filesystem scanning
93+
- Enhanced error response creation with proper Lex formatting
94+
- Maintained all existing functionality while improving developer experience
2595

2696
## [0.0.1] - 2025-01-03
2797

0 commit comments

Comments
 (0)