Skip to content

Fix AmazonSqs/AmazonSns Transport.ResourceUri throwing ArgumentNullException when only RegionEndpoint is set (closes #3115) - #3119

Merged
jeremydmiller merged 2 commits into
mainfrom
fix-3115-sqs-resourceuri-region
Jun 16, 2026
Merged

jeremydmiller merged 2 commits into
mainfrom
fix-3115-sqs-resourceuri-region

Conversation

@jeremydmiller

@jeremydmiller jeremydmiller commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

Problem

AmazonSqsTransport.ResourceUri was implemented as:

public override Uri ResourceUri => new Uri(Config.ServiceURL);

When the SQS transport is configured with a RegionEndpoint (the normal AWS path) rather than an explicit ServiceURL (used for LocalStack), Config.ServiceURL is null, so new Uri(null) throws ArgumentNullException. ResourceUri is documented on IBrokerTransport as purely diagnostic, so it should never throw.

The sibling AmazonSnsTransport.ResourceUri had the identical new Uri(SnsConfig.ServiceURL) shape and the same defect.

Closes #3115.

Fix

Both AmazonSqsTransport.ResourceUri and AmazonSnsTransport.ResourceUri now:

  1. Prefer an explicit ServiceURL when set (preserves existing LocalStack behavior).
  2. Fall back to a region-derived endpoint (https://sqs.{region}.amazonaws.com / https://sns.{region}.amazonaws.com) when only RegionEndpoint is configured.
  3. Use a generic sqs://amazon / sns://amazon placeholder when neither is configured.

Region resolution is wrapped in a guard since the AWS SDK's RegionEndpoint getter can probe ambient configuration — that path can't throw out of a diagnostic property either.

Tests

Added three broker-free tests to each of AmazonSqsTransportTests and AmazonSnsTransportTests:

All tests in both suites pass (SQS: 10, SNS: 9).

🤖 Generated with Claude Code

jeremydmiller and others added 2 commits June 16, 2026 11:24
…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>
@jeremydmiller jeremydmiller changed the title Fix AmazonSqsTransport.ResourceUri throwing ArgumentNullException when only RegionEndpoint is set (closes #3115) Fix AmazonSqs/AmazonSns Transport.ResourceUri throwing ArgumentNullException when only RegionEndpoint is set (closes #3115) Jun 16, 2026
@jeremydmiller
jeremydmiller merged commit 3c8da06 into main Jun 16, 2026
23 checks passed
This was referenced Jun 16, 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.

AmazonSqsTransport.ResourceUri throws ArgumentNullException when RegionEndpoint is not explicitly set

1 participant