fix: P27 — attribute subscriber-config warnings to the user's call site#69
Merged
Conversation
The five misconfig UserWarnings in _validate_subscriber_config used a static stacklevel=4, correct only for the direct @broker.subscriber path. Through the FastAPI OutboxRouter (which adds frames) it landed on a faststream-internal frame, so the warning pointed at library code instead of the user's decorator. Switch to warnings.warn(..., skip_file_prefixes=_WARN_SKIP_PREFIXES) (3.12+), skipping frames inside faststream_outbox and faststream — the warning is now attributed to the first caller frame outside both packages, correct for both the direct and router paths. requires-python is >=3.13, so the param is available. Adds test_subscriber_misconfig_warning_attributed_to_user_via_fastapi_router (mutation-verified: red under the old stacklevel=4). Full suite: 473 passed, 100% coverage; ruff + ty clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
3 tasks
lesnik512
added a commit
that referenced
this pull request
Jun 13, 2026
Covers the post-0.9.0 work: suspected findings S1–S5 (#68), the P27 warning- attribution fix (#69), and the P29/P30 test-broker cleanup (#70). Patch bump — fixes/hardening only, no new breaking changes; the one opt-in behavior change is validate_schema() now catching partial-index predicate drift. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
lesnik512
added a commit
that referenced
this pull request
Jun 13, 2026
…ings (#71) The 2026-06-12 code audit shipped across 0.9.0 (#61/#66/#67) and 0.9.1 (#68/#69/#70), but the invariant docs still described pre-fix behavior. Sync the drift the audit flagged plus the drift its own fixes introduced, and retire the now-resolved findings doc. CLAUDE.md / architecture: - relay: `_OutboxConfigError` no longer "rides AcknowledgementMiddleware to the nack path" — the worker catches it, logs at ERROR, and the row retries via lease expiry, not the retry_strategy (P18). Fixed in both CLAUDE.md and architecture/relay.md. - terminal-write API: `delete_with_lease(conn, …)` / `mark_pending_with_lease(conn, …)`, not the `*_with_conn` names. - NOTIFY: over-long table names now raise ValueError at construction (P7), not "silently lose NOTIFY and degrade to polling". - engine ownership: drop the phantom `EngineState` holder and the dead `OutboxBrokerConfig.disconnect()` (removed in P24). - schema: note the P8 `<table>_lease_ck` CHECK; validate_schema now also probes partial-index predicates (S2). - drain regression-test references point at the real test names (T8 added them to test_fake.py; integration covers the Postgres path). - timers NOTIFY-skip: "genuinely future-dated" wording (a past/zero activate_at/in does fire NOTIFY). Archive: - move planning/active/2026-06-12-code-audit-findings.md → planning/archived/ with status: shipped + PR/release provenance. - repoint the two release-notes "See also" links to archived/. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the audit's last skipped item, P27. The five misconfiguration
UserWarnings in_validate_subscriber_config(REJECT_ON_ERROR+ retry,NACK_ON_ERROR+NoRetry,max_deliverieswithout retry,lease_ttl <= max_fetch_interval) used a staticstacklevel=4. That's correct only for the direct@broker.subscriber(...)path; through the FastAPIOutboxRouter(which adds frames) it landed on a faststream-internal frame, so the warning pointed at library code instead of the user's decorator line.Fix
Switched to
warnings.warn(..., skip_file_prefixes=_WARN_SKIP_PREFIXES)(Python 3.12+;requires-pythonis>=3.13). The prefixes are thefaststream_outboxandfaststreampackage dirs, so the warning is attributed to the first caller frame outside both packages — correct for the direct and router paths, with no fragile frame-counting.Test
test_subscriber_misconfig_warning_attributed_to_user_via_fastapi_routerregisters a misconfigured subscriber through the FastAPIOutboxRouterand asserts the captured warning'sfilenameis the test file (the user), not a package frame. Mutation-verified: red under the oldstacklevel=4(it pointed at a faststream frame), green withskip_file_prefixes.Test Plan
stacklevel=4pytest.warns-based factory tests unaffected (they assert message, not location)Behavior unchanged — the warnings still fire identically; only their reported source location is corrected. Next: the P29+P30 test-broker cleanup PR.
🤖 Generated with Claude Code