Skip to content

Database queue Uris sanitize the queue name like the fluent API does - #3865

Merged
jeremydmiller merged 1 commit into
mainfrom
gh-dash-queue-uri/sanitize-db-queue-uris
Aug 6, 2026
Merged

jeremydmiller merged 1 commit into
mainfrom
gh-dash-queue-uri/sanitize-db-queue-uris

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

The bug (field report via CritterWatch)

wolverineOptions.AddCritterWatchMonitoring(
    critterWatchUri: new Uri("sqlserver://critterwatch"),
    systemControlUri: new Uri("sqlserver://my-service-control"));

fails at auto-provision time with invalid SQL — the dash reaches the queue table DDL unbracketed:

CREATE TABLE myapp_cw_control.wolverine_queue_my-service-control ( ... )

Root cause

The fluent API (ListenToSqlServerQueue / ToSqlServerQueue and siblings) runs queue names through MaybeCorrectName → SanitizeIdentifier (dash → underscore, lowercase). But a queue reached only by Uri (ListenForMessagesFrom(uri), publish-to-uri, etc.) resolves through findEndpointByUri, which did a raw Queues[uri.Host] — and the ctor of each database queue interpolates that raw name straight into the wolverine_queue_* table names. Same asymmetry in the SQL Server, PostgreSQL, SQLite, and MySQL transports.

The fix

findEndpointByUri in all four transports now runs the host through SanitizeIdentifier, extending the Oracle transport's GH-3820 correction (which fixed the same lookup for casing) to its siblings. SanitizeIdentifier rather than MaybeCorrectName: a Uri built from an already-corrected name carries any IdentifierPrefix, which MaybeCorrectName would prepend a second time. SanitizeIdentifier is idempotent, so fluent-registered queues resolve to the same endpoint they always did — covered by the new resolve-to-same-endpoint tests in each transport's suite.

The NServiceBus/MassTransit interop transports keep their own verbatim findEndpointByUri overrides — foreign endpoint names are matched exactly by design, so they are deliberately untouched.

Tests

New endpoint-resolution tests (no database needed) in SqlServerTests, PostgresqlTests, SqliteTests, and MySqlTests: a dashed Uri resolves to the sanitized queue name, and the dashed Uri, the fluent-corrected name, and the queue's own round-tripped Uri all resolve to the same endpoint (no second endpoint minted over the same tables). All pass on net9.0 + net10.0.

🤖 Generated with Claude Code

A queue reached only by Uri — e.g. ListenForMessagesFrom(new Uri("sqlserver://my-service-control")),
which is exactly what Wolverine.CritterWatch's systemControlUri does — bypassed the fluent API's
MaybeCorrectName and carried the raw host into SqlServerQueue/PostgresqlQueue/SqliteQueue/MySqlQueue,
where it is interpolated into the wolverine_queue_* table names. A dash in the name then produced
invalid, unquoted DDL at auto-provision time:

    CREATE TABLE myapp_cw_control.wolverine_queue_my-service-control ( ... )

findEndpointByUri in all four database transports now runs the host through SanitizeIdentifier,
matching the Oracle transport's GH-3820 correction. SanitizeIdentifier rather than MaybeCorrectName
because a Uri built from an already-corrected name carries any IdentifierPrefix, which
MaybeCorrectName would prepend a second time; SanitizeIdentifier is idempotent, so fluent-registered
queues resolve to the same endpoint they always did (covered by the new resolve-to-same-endpoint
tests). The NServiceBus/MassTransit interop transports keep their own verbatim findEndpointByUri
overrides — foreign endpoint names are matched exactly by design.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jeremydmiller
jeremydmiller merged commit c9292c1 into main Aug 6, 2026
69 of 70 checks passed
This was referenced Aug 7, 2026
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.

1 participant