Fix AmazonSqs/AmazonSns Transport.ResourceUri throwing ArgumentNullException when only RegionEndpoint is set (closes #3115) - #3119
Merged
Conversation
…is set (closes #3115) ResourceUri was `new Uri(Config.ServiceURL)`, which threw ArgumentNullException whenever the SQS transport was configured with a RegionEndpoint (the normal AWS path) rather than an explicit ServiceURL (LocalStack). ResourceUri is purely diagnostic, so it should never throw. It now prefers an explicit ServiceURL, falls back to a region-derived endpoint (https://sqs.{region}.amazonaws.com) when only RegionEndpoint is set, and uses a generic sqs://amazon placeholder when neither is configured. Region resolution is guarded so ambient-config probing can't throw either. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
AmazonSnsTransport.ResourceUri had the identical `new Uri(SnsConfig.ServiceURL)` shape and threw ArgumentNullException when only RegionEndpoint was configured. Mirror the SQS fix: prefer ServiceURL, fall back to https://sns.{region}.amazonaws.com, then a generic sns://amazon placeholder, with guarded region resolution. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 16, 2026
Merged
This was referenced Jul 20, 2026
This was referenced Jul 27, 2026
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.
Problem
AmazonSqsTransport.ResourceUriwas implemented as:When the SQS transport is configured with a
RegionEndpoint(the normal AWS path) rather than an explicitServiceURL(used for LocalStack),Config.ServiceURLisnull, sonew Uri(null)throwsArgumentNullException.ResourceUriis documented onIBrokerTransportas purely diagnostic, so it should never throw.The sibling
AmazonSnsTransport.ResourceUrihad the identicalnew Uri(SnsConfig.ServiceURL)shape and the same defect.Closes #3115.
Fix
Both
AmazonSqsTransport.ResourceUriandAmazonSnsTransport.ResourceUrinow:ServiceURLwhen set (preserves existing LocalStack behavior).https://sqs.{region}.amazonaws.com/https://sns.{region}.amazonaws.com) when onlyRegionEndpointis configured.sqs://amazon/sns://amazonplaceholder when neither is configured.Region resolution is wrapped in a guard since the AWS SDK's
RegionEndpointgetter can probe ambient configuration — that path can't throw out of a diagnostic property either.Tests
Added three broker-free tests to each of
AmazonSqsTransportTestsandAmazonSnsTransportTests:resource_uri_uses_explicit_service_url_when_setresource_uri_falls_back_to_region_when_service_url_not_set(the AmazonSqsTransport.ResourceUri throws ArgumentNullException when RegionEndpoint is not explicitly set #3115 regression)resource_uri_does_not_throw_when_neither_service_url_nor_region_setAll tests in both suites pass (SQS: 10, SNS: 9).
🤖 Generated with Claude Code