floci-io/floci · error · AwsException

InvalidInput

InvalidInput

Error message

Vpc is required for a private DNS namespace.

What it means

A private DNS namespace in Cloud Map is bound to a VPC, so CreatePrivateDnsNamespace requires a non-null, non-blank Vpc value. Floci checks this in createPrivateDnsNamespace and throws InvalidInput (HTTP 400) when the VPC argument is missing. AWS returns the same code for the same reason.

Source

Thrown at src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapService.java:94

    public Operation createHttpNamespace(String name, String creatorRequestId,
                                         String description, Map<String, String> tags, String region) {
        Namespace ns = newNamespace(name, "HTTP", description, creatorRequestId, tags, region);
        namespaceStore.put(ns.getId(), ns);
        return submitOperation("CREATE_NAMESPACE", "NAMESPACE", ns.getId(), region);
    }

    public Operation createPublicDnsNamespace(String name, String creatorRequestId,
                                              String description, Map<String, String> tags, String region) {
        Namespace ns = newNamespace(name, "DNS_PUBLIC", description, creatorRequestId, tags, region);
        ns.setHostedZoneId(generateHostedZoneId());
        namespaceStore.put(ns.getId(), ns);
        return submitOperation("CREATE_NAMESPACE", "NAMESPACE", ns.getId(), region);
    }

    public Operation createPrivateDnsNamespace(String name, String vpc, String creatorRequestId,
                                               String description, Map<String, String> tags, String region) {
        if (vpc == null || vpc.isBlank()) {
            throw new AwsException("InvalidInput", "Vpc is required for a private DNS namespace.", 400);
        }
        Namespace ns = newNamespace(name, "DNS_PRIVATE", description, creatorRequestId, tags, region);
        ns.setVpc(vpc);
        ns.setHostedZoneId(generateHostedZoneId());
        namespaceStore.put(ns.getId(), ns);
        return submitOperation("CREATE_NAMESPACE", "NAMESPACE", ns.getId(), region);
    }

    private Namespace newNamespace(String name, String type, String description,
                                   String creatorRequestId, Map<String, String> tags, String region) {
        if (name == null || name.isBlank()) {
            throw new AwsException("InvalidInput", "Namespace name is required.", 400);
        }
        boolean exists = scan(namespaceStore).stream()
                .anyMatch(n -> region.equals(n.getRegion()) && name.equals(n.getName()));
        if (exists) {
            throw new AwsException("NamespaceAlreadyExists",
                    "A namespace named \"" + name + "\" already exists.", 400);

View on GitHub (pinned to 62ff490619)

Solutions

  1. Pass the VPC ID (e.g. "vpc-0123456789abcdef0") in the CreatePrivateDnsNamespace request
  2. If you do not need VPC-scoped DNS, use CreatePublicDnsNamespace instead
  3. Validate the VPC ID exists in your EC2/emulator setup before creating the namespace

Example fix

// before
cloudMapClient.createPrivateDnsNamespace(r -> r
    .name("corp.example.internal")
    .creatorRequestId("ns-1"));

// after
cloudMapClient.createPrivateDnsNamespace(r -> r
    .name("corp.example.internal")
    .vpc("vpc-0123456789abcdef0")
    .creatorRequestId("ns-1"));
Defensive patterns

Strategy: validation

Validate before calling

if (vpcId == null || vpcId.isBlank()) {
    throw new IllegalArgumentException("VPC id is required for a private DNS namespace");
}
cloudMapClient.createPrivateDnsNamespace(r -> r.name(name).vpc(vpcId));

Prevention

When it happens

Trigger: CreatePrivateDnsNamespace (or the HTTP API POST /service-discovery namespace with Type=DNS_PRIVATE) with Vpc omitted, null, or whitespace. Note the public variant createPublicDnsNamespace takes no VPC, so switching namespace type without updating arguments is a common path here.

Common situations: Refactoring a public-namespace call into a private one and forgetting the VPC parameter; the SDK builder skipping .vpc(...) because it is optional in the model; wrong overload chosen at compile time.

Related errors


AI-assisted analysis of floci-io/floci@62ff490619 (2026-08-14). Data as JSON: /api/errors/7f0dd0ceae6906b3. Report an issue: GitHub.