Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

0.4.0#12

Merged
orenlab merged 36 commits into
mainfrom
0.4.0
Feb 13, 2026
Merged

0.4.0#12
orenlab merged 36 commits into
mainfrom
0.4.0

Conversation

@orenlab

@orenlab orenlab commented Feb 13, 2026

Copy link
Copy Markdown
Owner

No description provided.

orenlab added 30 commits June 8, 2025 18:17
…eatures are as follows. However, the code in this commit is not stable and contains errors and artifacts, making it unsuitable for productive use.

### Added

- **Circuit Breaker Pattern**:
    - Full circuit breaker implementation with `AsyncCircuitBreaker` class
    - Three states: CLOSED, OPEN, HALF_OPEN with automatic transitions
    - Configurable failure thresholds, recovery timeouts, and success thresholds
    - Sliding window failure rate calculation with exponential backoff
    - Event callbacks for state changes and call results monitoring
    - Health checker integration for automatic recovery detection
    - Background monitoring tasks for health checks and metrics cleanup

- **Advanced Health Monitoring**:
    - `HealthMonitoringMixin` for comprehensive health tracking
    - `OutlineHealthChecker` with cached health verification
    - `PerformanceMetrics` for detailed performance tracking
    - Real-time metrics collection: success rates, response times, circuit trips
    - Comprehensive health checks with individual component status
    - `health_check()` method with detailed metrics and circuit breaker status

- **Enhanced Configuration Management**:
    - `OutlineClientConfig` dataclass for immutable configuration
    - Environment variable loading with `from_env()` factory method
    - `.env` file support with automatic template generation
    - Comprehensive validation for all configuration parameters
    - `create_env_template()` utility for setup assistance
    - Configuration validation with detailed error messages

- **Batch Operations**:
    - `BatchOperationsMixin` with generic batch processor
    - `batch_create_access_keys()` for multiple key creation
    - `batch_delete_access_keys()` for bulk key deletion
    - `batch_rename_access_keys()` for mass key renaming
    - `batch_operations_with_resilience()` for custom batch operations
    - Configurable concurrency control and fail-fast options

- **Advanced Error Handling**:
    - Enhanced `ResponseParser` with detailed validation error formatting
    - Helpful error suggestions and context for common issues
    - Safe parsing with fallback to raw JSON on validation errors
    - Improved error messages with field paths and input values
    - Graceful handling of empty names and missing fields from API

- **Modular Architecture**:
    - Mixin-based design for clean separation of concerns
    - `ServerManagementMixin`, `MetricsMixin`, `AccessKeyMixin`, `DataLimitMixin`
    - Protocol-based type safety with `HTTPClientProtocol`
    - Enhanced type annotations with proper generic support

- **Enhanced Client Features**:
    - `create_resilient_client()` factory with conservative settings
    - `get_server_summary()` for comprehensive server overview
    - `wait_for_healthy_state()` for health state monitoring
    - Dynamic circuit breaker reconfiguration
    - Connection info and detailed status properties

- **Utility Functions**:
    - `quick_setup()` for interactive development setup
    - `get_version_info()` for package information
    - `create_config_template()` convenience wrapper
    - Interactive help display when imported in Python REPL
    - Comprehensive masking of sensitive data in logs

### Changed

- **Breaking Changes**:
    - Version bumped to 0.4.0 to reflect major feature additions
    - Client constructor now accepts many new parameters for circuit breaker and health monitoring
    - Default user agent updated to "PyOutlineAPI/0.4.0"
    - Enhanced error handling may change exception types in some edge cases

- **Enhanced Base Client**:
    - `BaseHTTPClient` now includes circuit breaker integration
    - Comprehensive logging setup without duplication
    - Enhanced session management with proper SSL context handling
    - Improved retry logic with circuit breaker awareness
    - Rate limiting support with configurable delays

- **Improved Type Safety**:
    - Better protocol definitions for HTTP client capabilities
    - Enhanced type hints with proper generic constraints
    - Improved overloads for response parsing methods
    - Stronger validation with `CommonValidators` utilities

- **Better Resource Management**:
    - Proper async context manager support throughout
    - Background task management in circuit breaker
    - Cleanup tasks for old metrics and call history
    - Enhanced session lifecycle management

- **Configuration Enhancements**:
    - All configuration now validated at initialization
    - Support for multiple environment variable prefixes
    - Comprehensive default values for all optional settings
    - Better error messages for configuration issues

### Fixed

- **Response Parsing**:
    - Better handling of empty name fields from Outline API
    - Improved validation error messages with actionable suggestions
    - Graceful fallback for unexpected response formats
    - Fixed handling of edge cases in metric responses

- **Connection Stability**:
    - Enhanced SSL certificate validation with proper error handling
    - Better handling of connection timeouts and retries
    - Improved cleanup of resources during failures
    - More robust session management

- **Logging**:
    - Eliminated duplicate log messages
    - Proper logger hierarchy setup
    - Configurable logging levels and formats
    - Performance-aware logging with conditional execution

- **Memory Management**:
    - Proper cleanup of circuit breaker background tasks
    - Sliding window size limits for call history
    - Weak references for callback management
    - Better resource cleanup in error scenarios

### Enhanced

- **Documentation**:
    - Comprehensive docstrings with usage examples
    - Better type annotations for IDE support
    - Enhanced error messages with troubleshooting hints
    - Interactive help and setup assistance

- **Developer Experience**:
    - Interactive setup with `quick_setup()` function
    - Automatic environment template creation
    - Better error messages for common configuration issues
    - Enhanced debugging capabilities with detailed metrics

- **Monitoring and Observability**:
    - Comprehensive performance metrics collection
    - Circuit breaker state monitoring with callbacks
    - Health check results with individual component status
    - Request/response time tracking and analysis
- code base optimization
- code refactoring
- new audit module
- multiple improvements in logic and performance
- a large number of utility methods for easier work with answers
- code base optimization
- code refactoring
- new audit module
- multiple improvements in logic and performance
- a large number of utility methods for easier work with answers
Multiple improvements in security, performance, and code quality (wop)
- code base optimization
- code refactoring
- new audit module
- multiple improvements in logic and performance
- a large number of utility methods for easier work with answers
- API Fix: Corrected DataLimit payload structure by wrapping it in a "limit" key as required by the Outline Server API (fixes issues with limits not being enforced).
- Security: Updated CredentialSanitizer regex to support complex API keys containing underscores, dashes, and dots (e.g., sk_live_ prefixes).
- Docs: Removed non-existent [metrics] dependency group from README and updated guides to reflect the latest changes.
- Tests: Synchronized model tests with the new API payload requirements.
Comment thread tests/test_base_client.py Dismissed
Comment thread tests/test_client.py
json_format=True,
)
client = AsyncOutlineClient(config=config)
assert client.config.api_url.startswith("https://example.com")

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization

The string [https://example.com](1) may be at an arbitrary position in the sanitized URL.
allow_private_networks=False,
resolve_dns=True,
)
assert url.startswith("https://example.com")

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization

The string [https://example.com](1) may be at an arbitrary position in the sanitized URL.
allow_private_networks=False,
resolve_dns=True,
)
assert url.startswith("https://example.com")

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization

The string [https://example.com](1) may be at an arbitrary position in the sanitized URL.
Comment thread tests/test_config.py
env_file = tmp_path / ".env"
_write_env(env_file)
config = OutlineClientConfig.from_env(env_file=env_file)
assert config.api_url.startswith("https://example.com")

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization

The string [https://example.com](1) may be at an arbitrary position in the sanitized URL.
Comment thread tests/test_config.py
env_file = tmp_path / ".env"
_write_env(env_file)
config = OutlineClientConfig.from_env(env_file=str(env_file))
assert config.api_url.startswith("https://example.com")

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization

The string [https://example.com](1) may be at an arbitrary position in the sanitized URL.
@sonarqubecloud

sonarqubecloud Bot commented Feb 13, 2026

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.1% Duplication on New Code

See analysis details on SonarQube Cloud

Comment thread pyoutlineapi/base_client.py Dismissed
Comment thread tests/conftest.py Dismissed
Comment thread tests/test_audit.py Dismissed
Comment thread tests/test_audit.py Dismissed
Comment thread tests/test_audit.py Dismissed
Comment thread tests/test_common_types.py Dismissed
Comment thread tests/test_common_types.py Dismissed
Comment thread tests/test_common_types_extra.py Dismissed
Comment thread tests/test_exceptions.py Dismissed
@codecov

codecov Bot commented Feb 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.83359% with 69 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pyoutlineapi/audit.py 92.88% 8 Missing and 11 partials ⚠️
pyoutlineapi/client.py 95.63% 0 Missing and 12 partials ⚠️
pyoutlineapi/metrics_collector.py 97.06% 0 Missing and 10 partials ⚠️
pyoutlineapi/circuit_breaker.py 95.31% 0 Missing and 9 partials ⚠️
pyoutlineapi/base_client.py 98.19% 1 Missing and 6 partials ⚠️
pyoutlineapi/common_types.py 98.78% 0 Missing and 4 partials ⚠️
pyoutlineapi/health_monitoring.py 98.81% 0 Missing and 3 partials ⚠️
pyoutlineapi/response_parser.py 96.80% 0 Missing and 3 partials ⚠️
pyoutlineapi/exceptions.py 99.50% 0 Missing and 1 partial ⚠️
pyoutlineapi/models.py 99.55% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
pyoutlineapi/__init__.py 100.00% <100.00%> (+14.28%) ⬆️
pyoutlineapi/api_mixins.py 100.00% <100.00%> (ø)
pyoutlineapi/batch_operations.py 100.00% <100.00%> (ø)
pyoutlineapi/config.py 100.00% <100.00%> (ø)
pyoutlineapi/exceptions.py 99.50% <99.50%> (-0.50%) ⬇️
pyoutlineapi/models.py 99.56% <99.55%> (+8.47%) ⬆️
pyoutlineapi/health_monitoring.py 98.81% <98.81%> (ø)
pyoutlineapi/response_parser.py 96.80% <96.80%> (ø)
pyoutlineapi/common_types.py 98.78% <98.78%> (ø)
pyoutlineapi/base_client.py 98.19% <98.19%> (ø)
... and 4 more

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants