Releases: dymmond/lilya
Releases · dymmond/lilya
Release list
Version 0.21.1
Added
- OpenTelemetry integration under
lilya.contrib.opentelemetry:- Introduced
OpenTelemetryMiddlewarefor automatic request tracing.- Creates one
SERVERspan per HTTP request. - Records standard HTTP attributes (
method,path,status,client.address,url.query, etc.). - Captures exceptions and marks spans with
StatusCode.ERROR. - Handles parent context extraction from inbound headers for trace propagation.
- Creates one
- Added
setup_tracing(config: OpenTelemetryConfig | None)helper.- Initializes a global
TracerProviderwith aBatchSpanProcessor. - Automatically selects between
ConsoleSpanExporter,OTLP/gRPC, andOTLP/HTTPexporters. - Safe to call multiple times (idempotent).
- Initializes a global
- Added
OpenTelemetryConfigdataclass for configuration.- Supports fields:
service_name: logical name reported to telemetry backends.exporter:"otlp"or"console".otlp_endpoint: e.g."http://localhost:4317"or"http://collector:4318".otlp_insecure: disable TLS verification for gRPC exporters.sampler:"parentbased_always_on","always_on", or"always_off".
- Supports fields:
- Added
get_tracer_provider()utility to retrieve the activeTracerProvider.
- Introduced
- Async testing utilities:
- Introduced AsyncTestClient and create_async_client() to allow fully asynchronous testing of Lilya apps.
- Both support full middleware stacks, including
OpenTelemetryMiddleware. - Enables concurrent request tests and real async span creation with in-memory exporters.
- Contrib Shortcuts:
- New abort function to raise HTTP exceptions.
- New responses shorcuts including:
send_json(): send JSON responses with proper headers.json_error(): send JSON error responses with status codes.stream(): stream response content from async generators.empty(): return empty 204 No Content responses.redirect(): send HTTP redirects with proper status codes and headers.forbidden(): send 403 Forbidden responses.not_found(): send 404 Not Found responses.unauthorized(): send 401 Unauthorized responses.
Changed
redirectnow is inlilya.contrib.responses.shortcuts.
Fixed
send_filenow correctly setsContent-Dispositionheaders for file downloads.- Late binding in the
make_response.
Version 0.21.0
Version 0.20.10
Fixed
- Validation
upper()was not being applied properly in the csrf token.
Version 0.20.9
This was supposed to go in the version 0.20.8 and it was forgotten.
Added
__exclude_from_openapi__Added to the base controller allowing the exclusion from the BaseTemplates.
Changed
- Lilya create project default was still using an old version of the generator.
Fixed
- OpenAPI documentation was not excluding templating system and statics.
Version 0.20.8
Added
itsdangerousto requirementsallandstandard.
Changed
@directive(display_in_cli=True)discovery improved by showing errors and not throw directly
an exception.- Update minimum Sayer version to 0.6.0.
- Custom directives under
@directiveare now displayed in a "Custom directives" group.
Version 0.20.7
Added
csrf_token_nameas new parameter in the Lilya settings. This will allow you to globally set the name of the
csrftoken when using CSRFMiddleware.csrf_enabledflag toTemplateController. This will automatically inject thecsrftoken in the context of the templates.csrf_token_form_nametoTemplateController. This defaults tocsrf_tokenand corresponds to the name of the variable
that is injected in the context of the template for the CSRF token whencsrf_enabled.- Support for
@directiveto be display when callinglilyaclient. - display_in_cli to
@directive.
Changed
- Make
responseoptional in theget_or_set_csrf_token.
Removed
- Wrong example for the CSRF token in the security with CSRF.
Version 0.20.6
Added
- Relay. This allows to create objects that are ASGI compatible and upstream services within your Lilya application.
- WebSocket proxying: Added full support for bidirectional WS proxying (text + binary frames).
- Retry & backoff: Configurable retry logic with exponential backoff on retryable statuses/exceptions.
- Timeout mapping: Upstream timeouts now map to
504 Gateway Timeout. - Header policies: Added support for allow-list mode (
allow_request_headers,allow_response_headers) in addition to drop-lists. - Structured logging: Proxy events (
upstream_error,upstream_timeout,upstream_retryable_error) now emit consistent log messages for observability. - Support for CSRFMiddleware to understand the HTML forms allowing also custom fields.
- New HTML response as an alternative to
HTMLResponse. - New documentation section for security with CSRF.
Changed
- Added
python-multipartas part of theallandstandardLilya packages. - Replaced
python-multipartwith a fully native multipart, urlencoded, and octet-stream form parser. - Improved RFC 5987 parameter decoding for proper handling of UTF-8 filenames and headers.
AuthenticationErrorexception is now located inlilya.exceptions.
Version 0.20.5
This was a change for the newer sayer 0.5.1 that affects the client.
Changed
- Allow minimum Sayer to be 0.5.1.
- Lilya cli now loses the
nameargument. This is now handled directly by the newest Sayer that
was internal refactored for the@callback.
Version 0.20.4
Changed
- Update sayer dependency version to 0.5.0 and pin it.
Version 0.20.3
Added
ValidationErroradded tolilya.exceptions.- Introduced lilya.contrib.mail providing a full-featured, async-first email framework.
- Includes a high-level
MailerAPI for sending single, multiple, and templated messages. - Supports multipart messages (text + HTML), custom headers, attachments (in-memory or files), and metadata.
- CLI integration,
lilya mail sendtest, for sending quick test emails via console backend.
Built-in Backends
- SMTPBackend: Async-friendly with connection pooling and TLS/authentication.
- ConsoleBackend: Writes messages to stdout for debugging.
- FileBackend: Saves emails as
.emlfiles for inspection or archiving. - InMemoryBackend: Stores emails in memory for development or testing scenarios.
Email Templates
- Added
TemplateRendererwith Jinja2 integration. send_templategenerates HTML + auto text fallbacks.- Supports separate text/HTML templates and contextual rendering.
Application Integration
- New
setup_mail(app, backend, template_dir, attach_lifecycle=True)utility attaches aMailertoapp.state.mailer. - Automatically opens/closes backend connections via startup/shutdown hooks.
Exception Hierarchy
MailError: Base exception for all mail errors.BackendNotConfigured: Raised when no backend or template renderer is configured.InvalidMessage: Raised when anEmailMessageis incomplete or malformed.