Skip to content

Host-prefixed requests fail when using a custom endpoint #7146

Open
@joe4dev

Description

@joe4dev

Checkboxes for prior research

Describe the bug

AWS SDKs add the host prefix defined in the Smithy model (e.g., sync- for sfn.StartSyncExecution) for custom endpoints (e.g., AWS_ENDPOINT_URL=http://127.0.0.1:4566), even if technically incompatible, for example sync-127.0.0.1.
This behavior is technically wrong, incompatible with the AWS standard for custom endpoints (https://docs.aws.amazon.com/sdkref/latest/guide/feature-ss-endpoints.html), and breaks emulator compatibility (e.g., LocalStack) of all host-prefixed operations (counting >562) for many AWS tools, including the AWS CLI, the AWS Toolkit, etc.

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/**@3.830.0 (Example: @aws-sdk/[email protected])

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v22.14.0

Reproduction Steps

  1. npm install @aws-sdk/[email protected]

  2. Run node minimal_example.js using the following script:

    import { SFNClient, StartSyncExecutionCommand } from "@aws-sdk/client-sfn";
    
    const client = new SFNClient({
        endpoint: "http://127.0.0.1:4566",
        region: "us-east-1",
        credentials: {
            accessKeyId: "test",
            secretAccessKey: "test",
        },
        maxAttempts: 1,
    });
    
    client.send(new StartSyncExecutionCommand({
        stateMachineArn: "arn:aws:states:us-east-1:000000000000:stateMachine:express_statemachine_83b68bea",
        input: "{}",
    }));

Link reproducer test suite (including botocore comparison): https://github.com/joe4dev/host-prefix-testing

Observed Behavior

The AWS SDKs add the host prefix for incompatible endpoint URLs, causing connection errors such as:

Error: AWS SDK error wrapper for Error: getaddrinfo ENOTFOUND sync-127.0.0.1

Expected Behavior

The AWS SDKs should omit the host prefix for incompatible endpoint URLs such as 127.0.0.1 and localhost. Maybe, the host prefix can be dropped altogether when using a custom endpoint.

Possible Solution

The implementation could be similar to the IPv4 detection in aws_is_virtual_hostable_s3_bucket applied through the endpoint rule set via aws.isVirtualHostableS3Bucket.

Additional Information/Context

The issue appears to be related to Smithy code generation, given that all AWS SDKs are affected.

Disclaimer: I work for LocalStack

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions