Releases: TTWShell/ZodiacCore-Py
Releases · TTWShell/ZodiacCore-Py
v0.9.1
Added
- HTTP: Log translated upstream HTTP errors with structured context, including service, error type, request method, upstream URL, status code, and capped upstream response body details.
- Exceptions: Include upstream status and response body details in
UpstreamRequestExceptionresponses for upstream HTTP 400/422 failures.
Fixed
- HTTP: Handle
httpx.RequestErrorinstances without request metadata without raising a secondary exception during upstream error translation. - Exception Handlers: Log inbound request context when returning standardized upstream error responses.
- Docs: Document upstream error logging fields and 400/422 response details.
v0.9.0
Added
- HTTP: Add
translate_upstream_errors(service)to converthttpxupstream status and request failures into standardized ZodiacCore exceptions for both async and sync functions. - Exceptions: Add
UpstreamServiceExceptionandUpstreamRequestExceptionfor explicit upstream service failures, including service name and upstream error classification. - Exception Handlers: Register a dedicated upstream exception handler that returns standardized HTTP 400 responses for translated upstream failures.
- Templates: Update the
standard-3tierexternal client example to useZodiacClientwithtranslate_upstream_errors. - Docs: Document upstream error translation, manual upstream business-error mapping, and the new upstream exception types in the exceptions API guide.
- Tests: Add coverage for upstream exception behavior, handler registration, async/sync HTTP translation, and template usage.
v0.8.1
Fixed
- Exceptions: Respect
http_codedeclared on directZodiacExceptionsubclasses when converting them to HTTP responses, while preserving fixed HTTP statuses for built-in exception families.
Changed
- Docs: Clarify the distinction between HTTP status codes and business error codes, including how built-in exception families and direct
ZodiacExceptionsubclasses should be used.
v0.8.0
Added
- CLI:
--package-nameoption forzodiac newcommand to customize the generated Python package name (defaults toapp). - Middleware:
ServiceNameMiddlewarefor scoping service names in request context, allowing per-app log attribution in multi-app deployments. - Context:
service_name_scopeandget_service_namefor managing service-level context inzodiac_core.context. - Logging: Loguru patcher now prefers
service_namefrom context if available, enabling accurate service tagging in shared logging sinks. - Templates:
standard-3tiertemplate now fully supports dynamic package names and includesServiceNameMiddlewareregistration by default. - Tests: Comprehensive multi-app integration tests (
tests/multi_app/dual_full_apps/) using real Uvicorn servers to validate isolation and shared resources.
Changed
- CLI:
zodiac newnow validates package names against Python identifiers and reserved names (main,config,tests). - Middleware:
register_middlewarenow accepts an optionalservice_nameto automatically enableServiceNameMiddleware. - Docs: Documentation updated with
--package-nameusage and architectural details for multi-app setups.
v0.7.0
Added
- Database:
get_session()accepts an optionalnameparameter for multi-database support; defaults to the default database for backward compatibility. - Config:
StrictConfigbase model (extra='forbid',frozen=True) for configuration section Pydantic models — rejects typo keys and prevents mutation after creation. - Utils:
strtobool()as a Python 3.13+ compatible drop-in replacement for the removeddistutils.util.strtobool, returningboolinstead ofint. - Docs: Best practices guide for
dependency-injectorConfiguration (strict mode, required files, type conversion pitfalls, environment variable interpolation). - Docs: API reference page for the
zodiac_core.utilsmodule. - Tests: Integration tests for
dependency-injectorstrict=True+required=True+as_(strtobool)andStrictConfigconstraints;dependency-injectoradded as dev dependency.
Changed
- Template: Generated projects use
providers.Configuration(strict=True)andfrom_ini(path, required=True)for fail-fast configuration loading. - Template: Config models (
DbConfig,CacheConfig) inheritStrictConfiginstead ofBaseModel; type conversion uses Pydantic models viaConfigManagement.provide_config()instead of manualas_()calls. - Docs: All code examples across config, context, architecture, and getting-started guides updated to use
strict=True,required=True, andstrtoboolimports fromzodiac_core.utils.
Fixed
- Config: Replace
as_(bool)/as_=boolwithas_(strtobool)for boolean config values —bool("false")evaluates toTrue, causing silent misconfiguration. - Tests: Force reinstall
zodiac-corein generated project quality test to prevent staleuvcache from masking template breakage.
v0.6.1
Added
- Cache: Optional
include_clsandinclude_selfon@cachedso the default key builder can fold receiver class identity into the key forclassmethods (cls) and instance methods (self), gated by conventional first-parameter names; document thatinclude_selfis class-scoped (not per-instance) and that inheritance changes cache partitioning when enabled. - Tests: Expand
@cachedcoverage for customkey_builder,include_clswith base/derived classes,include_selfsharing across instances of the same class, parent/child class separation, and instance methods that still require an explicitkey_builderwhen receiver-aware keys are omitted.
Changed
- Docs: Add a “Receiver-aware default keys” section to the cache API guide (constraints, warnings, and examples for class vs instance methods).
v0.6.0
Added
- HTTP: Add
init_http_client()as a lifecycle helper for creating and closing a sharedZodiacClientwithin an application or DI resource. - Database: Add scoped shutdown support via
db.shutdown(name="...")so a single named database can be released without disposing all registered engines. - Cache: Add scoped shutdown support via
cache.shutdown(name="...")so a single named cache can be released without clearing all registered caches. - Tests: Add coverage for named database/cache shutdown and for
init_db_resource()cleaning up only its own database name.
Changed
- Database: Make
DatabaseManager.setup()deterministic by allowing repeated setup only for the same effective configuration and raisingRuntimeErrorfor conflicting configuration on an existing name. - Database: Make
init_db_resource()release only the database registered under its ownname, preserving other shared database resources in the same process. - Template: Manage the shared HTTP client as an application resource in the standard 3-tier template and initialize app resources through
AsyncExitStack. - Template: Align generated project configuration loading with
APPLICATION_ENVIRONMENTand default the template fallback environment todevelop. - CLI: Clarify that
zodiac new --forceallows generation into an existing directory without removing unrelated files. - Docs: Update database, cache, config, context, architecture, CLI, and getting-started documentation to reflect the scoped resource lifecycle and template conventions.
Fixed
- Template: Ensure generated projects use resource lifecycle management for shared HTTP clients instead of relying on unmanaged singleton client instances.
v0.5.4
Changed
- Cache: Restrict the default
@cachedkey builder to stable immutable parameters and require an explicitkey_builderfor complex arguments instead of falling back to unstable automatic keys. - Cache: Make
cache.setup(...)deterministic by allowing repeated setup only for identical effective configuration and raisingRuntimeErrorfor conflicting settings. - Docs: Clarify cache setup idempotency rules and document the supported/default key-builder constraints for
@cached.
Fixed
- Cache: Decode the internal cached-
Nonesentinel in publicget()while preserving correctget_or_set()hit detection under lock rechecks. - Cache: Preserve
default_ttlwhen rebuilding aZodiacCachewrapper from an existing aiocache alias.
Added
- Tests: Expand cache coverage for tuple-based default keys, deterministic setup behavior, wrapper rebuild state, public
get()after cachedNone, and the cached-Nonelock recheck path.
v0.5.3
Fixed
- Logging: When
json_format=True, use empty"text"in serialized JSON so the message appears only inrecord.message, avoiding duplication and reducing log size (loguru#594).
Changed
- Logging: Unify console and file sink defaults in
setup_loguru()via shared_sink_defaultsand_apply_sink_defaults(); document empty-text behavior and override viaconsole_options/file_optionsin docstring.
v0.5.2
Fixed
- HTTP: Use
HTTP_422_UNPROCESSABLE_CONTENT(RFC 9110) instead of deprecatedHTTP_422_UNPROCESSABLE_ENTITYinUnprocessableEntityExceptionandresponse_unprocessable_entity(), resolving Starlette deprecation warnings.
Changed
- Dependencies: Require
starlette>=0.48.0so the RFC 9110 status constant is available.