Skip to content

EC2: DescribeInstanceTypes returns empty instead of InvalidInstanceType, and DescribeInstanceTypeOfferings ignores the instance-type filter #485

Closed

Description

@scttfrdmn

Two related defects in the operations #234 added, plus the catalog gap behind
them. Probed against ghcr.io/scttfrdmn/substrate:0.85.0 and diffed against real
us-east-1.

1. DescribeInstanceTypes returns an empty list where AWS raises

An unknown instance type is answered with HTTP 200 and no results:

substrate:  zz9.nonexistent -> HTTP 200, 0 results
real AWS:   InvalidInstanceType: The following supplied instance types do not exist: [zz9.nonexistent]

This is the same failure shape as #391 (unknown instance ID returned 200 + empty
list instead of InvalidInstanceID.NotFound), and it matters for the same reason.
#391's fix was load-bearing downstream: it turned out to have been silently
defeating
a validation guard in parsl-aws-provider — a resource-verification
path never raised, so the check was skipped while tests still reported green.
An empty list is indistinguishable from "not in the catalog", so a caller
validating a user-supplied instance type gets no signal.

2. The instance-type filter on DescribeInstanceTypeOfferings is ignored

substrate:  Filters=[{instance-type: m5.xlarge}] -> 24 offerings, distinct types:
            [c5.2xlarge, c5.xlarge, g4dn.xlarge, inf1.xlarge, m5.large,
             p3.2xlarge, r5.xlarge, t3.micro]      # all 8 x 3 AZs
real AWS:   Filters=[{instance-type: m5.xlarge}] -> 5 offerings, distinct types: [m5.xlarge]

substrate:  Filters=[{instance-type: zz9.bogus}]  -> 24 offerings
real AWS:   Filters=[{instance-type: zz9.bogus}]  -> 0 offerings

Every offering for every catalog type comes back regardless of the filter, so a
caller asking "is m5.xlarge offered in this AZ?" gets yes for any input,
including nonsense.

The cause is in describeInstanceTypeOfferings (emulator/ec2_plugin.go:4021).
It builds wantedTypes from InstanceType.N request params:

wantedTypes := map[string]bool{}
for i := 1; ; i++ {
    v := req.Params[fmt.Sprintf("InstanceType.%d", i)]
    ...
}

But DescribeInstanceTypeOfferings has no InstanceTypes parameter — botocore
rejects it outright:

ParamValidationError: Unknown parameter in input: "InstanceTypes",
must be one of: DryRun, LocationType, Filters, MaxResults, NextToken

So wantedTypes is always empty, len(wantedTypes) > 0 is never true, and the
filter loop is dead code. Only location is read from Filter.N.Name
(ec2_plugin.go:4028); instance-type is never consulted. The sibling
describeInstanceTypes at :3960 reads InstanceType.N correctly — there the
parameter does exist — which is likely how the pattern got copied across.

Real AWS supports at least instance-type, location, and location-type as
filter names here.

3. The catalog is 8 hardcoded types, and the gaps are arbitrary

ec2InstanceTypeCatalog (ec2_plugin.go:3921) is the ~8 types #234 asked for:
t3.micro, c5.xlarge, c5.2xlarge, m5.large, r5.xlarge, p3.2xlarge,
g4dn.xlarge, inf1.xlarge. Which sizes made the cut is incidental to that
issue's consumer, and it splits families mid-way — for the ten types
parsl-aws-provider references:

t3.micro     present        m5.large     present
t3.small     ABSENT         m5.xlarge    ABSENT
t3.medium    ABSENT         m5a.large    ABSENT
t3a.small    ABSENT         c5.large     ABSENT
t3a.medium   ABSENT         c5.xlarge    present

c5.xlarge and c5.2xlarge are in, c5.large is out; m5.large is in,
m5.xlarge is out. Nothing wrong with a seeded catalog — the ask is that it cover
whole families for the common general-purpose/compute/burstable ones, or that
missing entries be distinguishable from bad input (which is item 1).

Why it matters to a consumer

In parsl-aws-provider, instance
type selection and capacity probing are provider behaviour, and its
describe_instance_capacity tests stay on moto because of items 1 and 3 —
they need a type outside these 8 and need an unknown type to raise. That's one of
three remaining reasons
parsl-aws-provider#183
("retire moto where substrate now suffices") could only be answered partially.

Items 1 and 2 are the ones I'd call bugs — they're wire-behaviour divergences
where substrate answers success to something real AWS refuses, and item 2 makes
an offerings query unable to fail. Item 3 is a coverage request and the least
urgent.

Reproduce

import boto3
ec2 = boto3.client("ec2", endpoint_url="http://localhost:4566",
                   region_name="us-east-1",
                   aws_access_key_id="test", aws_secret_access_key="test")

# 1: expected InvalidInstanceType
print(len(ec2.describe_instance_types(InstanceTypes=["zz9.nonexistent"])["InstanceTypes"]))  # 0

# 2: filter ignored -> 24, and 24 again for a bogus type
for t in ("m5.xlarge", "zz9.bogus"):
    r = ec2.describe_instance_type_offerings(
        LocationType="availability-zone",
        Filters=[{"Name": "instance-type", "Values": [t]}])["InstanceTypeOfferings"]
    print(t, len(r), sorted({o["InstanceType"] for o in r}))

Activity

  1. added
    type: bug
    priority: medium
    on Aug 2, 2026
  2. added this to the v0.87.0 milestone on Aug 2, 2026
  3. scttfrdmn commented on Aug 2, 2026

    @scttfrdmn
    OwnerAuthor

    Fixed in 64912ef (#496), shipping in v0.87.0. All three of your items, and your aside about filter names was worth checking — the reference disagrees with both of us in one place.

    Your finding 2 is confirmed, and the cause is worse than "ignores the filter." describeInstanceTypeOfferings built its wantedTypes set from an InstanceType.N parameter, and the operation has no such parameter: DescribeInstanceTypeOfferings takes exactly DryRun, Filter.N, LocationType, MaxResults and NextToken. So the filter was not mis-implemented, it was unreachable dead code reading a parameter that cannot arrive. DescribeInstanceTypes does have InstanceType.N (max 100), and it sits directly above describeSpotPriceHistory in the same file — the loop was copied from a neighbour where it was correct.

    Correcting your aside: location-type is not a filter name. You wrote that the operation should support "at least instance-type, location, and location-type as filter names." The reference lists exactly two filters — instance-type and location. LocationType is a separate top-level parameter, not a Filter.N.Name value. Substrate now honours it as a parameter for availability-zone (the previous behaviour) and region (one offering per type, location = the region); availability-zone-id and outpost are unmodelled and docs/services.md says so rather than silently treating them as availability-zone.

    Also, a form your report does not mention but the reference documents: instance-type supports a wildcard suffix — "The instance type (for example c5.2xlarge or c5*)". Values=c5* now returns every c5-family member. Had we shipped only exact matching, the filter would have been "fixed" and still wrong for a documented input.

    The refuse-vs-empty asymmetry is deliberate, and it is the one thing to know before upgrading. DescribeInstanceTypes --instance-types zz9.nonexistent now returns InvalidInstanceType (400) — the code is documented in the EC2 client-error table ("The instance type is not supported for this request"), and the message ships verbatim from your capture, credited to it, since only your diff attests to the wording. Multiple unknown types produce one error naming all of them in request order, which is what your [zz9.nonexistent] list shape implies. But an instance-type filter naming an unknown type still returns zero offerings at HTTP 200, exactly as your real-AWS diff shows: a filter that matches nothing is a legitimate empty answer, while naming a type is an assertion that it exists. The two operations answer different questions and the doc now says which is which.

    Your item 3 was not optional, and that is worth being explicit about. With the old 8-type catalog, refusing anything absent would have turned every real-but-unmodelled type into InvalidInstanceType — the right code for zz9.nonexistent and badly wrong for m5.xlarge. So the catalog widened to whole families in the same commit (t3, t3a, m5, m5a, c5, c5a, r5, plus the existing accelerated entries), with vCPU and memory derived from family-and-size arithmetic and a handful of known-correct values pinned in a test. The old set split families mid-way — c5.xlarge in, c5.large out; m5.large in, m5.xlarge out — which is the kind of boundary nobody guesses. ec2SpotPriceCatalog moved in step, with a test asserting parity in both directions, because a type in one map and not the other was the next bug.

    The catalog is still seeded rather than exhaustive, and docs/services.md states that plainly along with what happens outside it — you need to know which answer you are getting.

    One thing your report did not ask for and did not get: DescribeInstanceTypes still ignores Filter.N entirely. That is a real gap, wider than this issue, and it is filed as #495.

    The Filter.N walk is now one function (ec2FilterValues) shared with describeSpotPriceHistory and describeRegions, each of which had its own partial copy. A copied loop is what caused this, so the copies are gone.

  4. added a commit that references this issue on Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: ec2priority: mediumtype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions