Skip to content

fix(client): calls keep their middleware chain and deliver all their events - #127

Merged
kalaspuff merged 1 commit into
issues-stack/1-codec-valuesfrom
issues-stack/2-client-details
Oct 31, 2026
Merged

kalaspuff merged 1 commit into
issues-stack/1-codec-valuesfrom
issues-stack/2-client-details

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Five smaller client issues of #96:

  • Middleware removed during a call: the chain indexed the live middleware list, so a one-shot middleware that called its remove() and then call_next made the next registered middleware (a guard, say) not run for that call, and a remove() from another task changed calls in flight. A call now runs the middleware registered when it starts; additions and removals apply to calls that start afterwards.
  • Events beyond 1024 per call: the drain after each call took at most 1024 events, so the rest waited for the event task or the next call, against "Events of a call reach hooks before the call returns", and testing.capture_events() missed them (a put throttled 600 times captured 1024 of its 1200 request events). The drain now takes them all, in batches of 1024.
  • LoggingConfig.levels precedence: the first matching pattern in the mapping's order won, so {"request.*": "debug", "request.gave_up": "error"} logged request.gave_up at DEBUG. An exact kind now wins over globs, and of the matching globs the longest ("request.gave_*" over "request.*" over "*"); globs as long keep the mapping's order. Documented in LoggingConfig, the configuration reference and the observability guide.
  • Star import without pydantic: __all__ listed PydanticModel, whose lazy import raises ImportError without pydantic, so from dynamoxy import * failed. It is now in __all__ only when pydantic is installed.
  • The docstring of the core's slow threshold named operation.slow; the event is request.slow.

Verified with unit tests, each failing without the fix: a self-removing middleware and one added during a call, a put throttled 600 times on a client without the event task whose 600 retry and 600 throttle events all reach a hook, level precedence for exact kinds and globs in both orders, and from dynamoxy import * in a subprocess with and without pydantic importable. make check passes.

Fixes #96

Checklist

  • Tests cover the change (in-memory backend; the changes are in the Python client)
  • Docs updated (observability guide, configuration reference, changelog)
  • make check passes locally (lint, types, clippy, consistency, tests)
  • Breaking change? No: only configurations whose glob order picked a less specific level log differently

Worth confirming

  • Decision: of several matching globs in LoggingConfig.levels, the longest wins (ties: the first in the mapping), rather than only "exact kind beats globs" with dict order among globs.
  • Decision: with pydantic installed, from dynamoxy import * still imports PydanticModel and so loads pydantic; without it, the star import leaves PydanticModel out instead of failing.

fctl session


Note

Low risk. The changes are in the Python client's middleware chain, event drain, log-level lookup and star import, with tests; the main behavior shifts are that a call keeps the middleware it started with and that logging levels for overlapping globs can change.

What it does. Fixes five small client problems from #96. A call now runs the middleware that was registered when it started, so a middleware that removes itself no longer makes the next one skip that call. The drain after each call now takes all buffered events in batches of 1024 instead of at most 1024, so hooks and capture_events() see every event before the call returns. LoggingConfig.levels now prefers an exact kind, then the longest matching glob, instead of the first match in dict order. PydanticModel is only listed in __all__ when pydantic is installed, so from dynamoxy import * works without it, and a docstring names request.slow instead of operation.slow.

Log level precedence. Configurations with overlapping globs in LoggingConfig.levels can log some events at a different level than before, since the longest glob now wins rather than the first one listed.

fctl review's first look at 27ac8f5 · 9 files, +167 −16 · Review agent settings

… events

A middleware removed during a call made the next registered one not
run for that call, as the chain indexed the live list: a call now runs
the middleware registered when it starts. Only 1024 events of a call
reached hooks before it returned; the rest waited for the next call.
LoggingConfig.levels took the first matching pattern in dict order; an
exact kind now wins over globs, and the longest matching glob over
shorter ones. `from dynamoxy import *` failed without pydantic, since
__all__ listed PydanticModel; it is listed only with pydantic installed.
The slow threshold's docstring named `operation.slow` for `request.slow`.

Fixes #96

Co-authored-by: Carl Oscar Aaro <[email protected]>
@kalaspuff
kalaspuff added this pull request to stack #136 October 31, 2026 03:58
@fctl-sh

fctl-sh Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Stack of 10 pull requests, merged in this order with "Squash and merge":

  1. fix(models): numbers of union fields render as stored, and literals of plain enum members write #126 fix(models): numbers of union fields render as stored, and literals of plain enum members write
  2. fix(client): calls keep their middleware chain and deliver all their events #127 fix(client): calls keep their middleware chain and deliver all their events ← this pull request
  3. fix(pydantic): use_enum_values, forward references, RootModel fields and data-taking factories work #128 fix(pydantic): use_enum_values, forward references, RootModel fields and data-taking factories work
  4. fix(unique)!: upserts that race with creates, unique floats written back, and collections refused #129 fix(unique)!: upserts that race with creates, unique floats written back, and collections refused
  5. fix(transactions): commit() no longer raises after the transaction was applied #130 fix(transactions): commit() no longer raises after the transaction was applied
  6. fix(telemetry): records and metrics count PartiQL writes, throttles of failed calls, batch retries and rows #131 fix(telemetry): records and metrics count PartiQL writes, throttles of failed calls, batch retries and rows
  7. fix(testing): purge_expired, inject_fault(table=) and replayed transactions behave like DynamoDB #132 fix(testing): purge_expired, inject_fault(table=) and replayed transactions behave like DynamoDB
  8. fix(memory): queries refuse empty key values and start keys outside the key condition, and index keys have size limits #133 fix(memory): queries refuse empty key values and start keys outside the key condition, and index keys have size limits
  9. fix(binding): conversions take any mapping and refuse invalid wire values, and unknown table statuses are not active #134 fix(binding): conversions take any mapping and refuse invalid wire values, and unknown table statuses are not active
  10. fix(memory): PartiQL and expressions follow DynamoDB's rules, and hand-written conditions get no redundant parentheses #135 fix(memory): PartiQL and expressions follow DynamoDB's rules, and hand-written conditions get no redundant parentheses

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client: removing middleware mid-call, events beyond 1024 per call, LoggingConfig precedence, star import

1 participant