Repository navigation
Description
Summary
Substrate has pricing providers (emulator/pricing.go, pricing_control.go) that consume AWS
pricing to attribute cost to simulated usage — but it does not emulate the Price List Query API
itself. There's no handler for api.pricing.<region>.amazonaws.com and no GetProducts /
DescribeServices / GetAttributeValues operation, so a client whose job is to call the Pricing
API has nothing to talk to.
Verified against 103c843 (v0.76.0):
$ grep -rn "GetProducts\|AWSPriceListService" --include="*.go" . | grep -v _test | grep -v ecs
(no matches)
Note this is the inverse direction from AWSPricingProvider, which fetches the public offer index
to price substrate's own simulated usage. I'm asking for the server side.
Why this matters to me
objectfs makes storage-tier recommendations, which means it
needs real rates. Today it ships a hardcoded table, and an audit found the table is wrong in ways
nobody noticed for four releases:
USW2-Requests-Tier1is $0.005 per 1,000 PUTs; the table says0.0005— 10× low.- Storage rates are duplicated across four separate places in the codebase, which had already
drifted apart from each other. - The drift test that exists compares only the storage-per-GB field, so it sails past the request-cost
error. - The configured
regionis read at exactly one line, for a summary string — soregion: us-west-2
produces us-east-1 numbers labelled us-west-2.
So I'm replacing it with the real API. Which means I need to test against a mock, because these calls
are reachable from the filesystem read path (GetObject → RecordAccess → calculateObjectCost) and
a pricing failure must never be able to fail a filesystem operation. That property — pricing degrades,
I/O does not — is only testable if I can make pricing fail on demand.
What I need
GetProducts on the AWSPriceListService target, and ideally DescribeServices /
GetAttributeValues.
The fidelity details are the entire point of the request. A clean, tidy mock would let my code
pass tests and then fail against real AWS. Each of these is something I verified against the live API
and got surprised by:
-
PriceListis[]string, not a list of objects. Each element is a raw JSON document as a
string, which the caller must unmarshal separately. This is the single most surprising part of the
API shape and the easiest thing for a mock to "clean up" into being wrong. -
pricePerUnitvalues are strings, e.g."0.0230000000"— not numbers. Trailing zeros and all. -
productFamilyis absent from most products. In the S3 offer file, 315 of 381 products
omit it. Any mock where every product has one will teach me to filter on a field that usually isn't
there.usagetypeis the only attribute I found to be reliably 1:1 and stable, and my
implementation is going to key on it — so please include realistically messyusagetypevalues
(USW2-Requests-Tier1,USW2-TimedStorage-ByteHrs,Requests-Tier1, …). -
At least one SKU with multiple
priceDimensions, including a tiered one whose last dimension
has"endRange": "Inf". Tiered pricing is where a naive "take the first dimension" parser silently
reports the wrong number. -
The Deep Archive trap. Filtering
productFamily=Storage+volumeType='Glacier Deep Archive'
returns a staging SKU priced at ~21× the real rate. I hit this. A mock containing only the
"obvious" SKU per tier would hide it; including a decoy staging SKU would make my filter's
specificity a tested property instead of a hope. -
Region behaviour.
us-west-2is not a Pricing API endpoint — onlyus-east-1and
ap-south-1are. The SDK'sEndpointResolverV2will happily template any well-formed region into
a hostname and hand you an opaque DNS failure rather than a validation error. If substrate rejects
non-endpoint regions with something legible, that's strictly better than what AWS does, and it's a
test I'd write.
Related: a bug in extractRegionFromHost
emulator/parser.go:411. For api.pricing.us-east-1.amazonaws.com it returns "pricing", not
"us-east-1".
After stripping .amazonaws.com, parts = ["api", "pricing", "us-east-1"]. There's no s3 token, so
the S3 loop doesn't fire; it isn't execute-api; so it falls through to the
"<service>.<region>" assumption at :441-444 and returns parts[1] — which is the second label of
a three-label host.
This is independent of everything above and presumably affects any other service using an
api.<service>.<region> hostname. Suggested shape: when len(parts) >= 3 && parts[0] == "api",
return parts[2]. More generally, a region looks like xx-yyyy-N, so validating the candidate
against that pattern before returning it would make the whole function fail closed instead of
returning a service name as a region.
Happy to split that into its own issue if you'd prefer it tracked separately — say the word.
Priority
Lowest of the batch. objectfs can ship v0.10.1 with a corrected static table and the public offer-file
URL as an unauthenticated fallback; native GetProducts emulation is what I'd want before making the
API the primary source. #396 (Range GET) is the one that's actually blocking me.
Acceptance
A GetProducts handler returning a small hand-built S3 offer fixture that exhibits all six
characteristics above, and a fix + test for extractRegionFromHost on api.pricing.us-east-1.amazonaws.com.
Activity
[-]Pricing: emulate the Price List Query API (GetProducts); plus extractRegionFromHost returns "pricing" for api.pricing.<region>[/-][+]Pricing: emulate the Price List Query API (GetProducts)[/+]scttfrdmn commentedon Jul 31, 2026
Split as you offered — the
extractRegionFromHostbug is now #403, and this issueis narrowed to the Price List Query API emulation. I confirmed the parser diagnosis
exactly as you described it (
emulator/parser.go:441-444returnsparts[1], thesecond label of a three-label host), and added one thing to #403: the function fails
open, returning a confident wrong answer rather than
"", so validating thecandidate against the
xx-yyyy-Nregion shape guards the whole class rather thanjust the
api.prefix. #403 is on v0.79.0.This issue is on v0.80.0. The six fidelity characteristics are the reason —
PriceListas[]stringof raw JSON documents, string-typedpricePerUnit,productFamilyabsent from most products, multi-dimension tiered SKUs with"endRange": "Inf", the Deep Archive staging decoy, and the us-east-1/ap-south-1endpoint restriction — none of which a hand-waved fixture would exercise. That is a
corpus to build carefully, not quickly, and you noted this is your lowest priority.
Two notes on the design while it is fresh:
want "pricing degrades, I/O does not" to be testable, which means
GetProductsneeds to fail on demand. That is exactly the seed pattern in
CLAUDE.md— acontrol-plane endpoint (
POST/DELETE /v1/pricing/...) keyed by service or"*"— rather than anything nondeterministic. I will build that alongside the handler,
not as a follow-up.
than AWS's opaque DNS failure, and I agree it should be substrate's behaviour.
Worth being explicit that this is a deliberate divergence from AWS, so it will be
documented as such rather than presented as parity.
scttfrdmn commentedon Jul 31, 2026
Implemented in #418. Two corrections to the issue, both verified against the live offer files rather than from memory — worth flagging because each one changes what your code should do.
The Price List API has three endpoints, not two. AWS lists
us-east-1,ap-south-1, andeu-central-1(Frankfurt). If you have region-gating logic that allows two, Frankfurt is being sent somewhere it doesn't need to go.The Deep Archive trap is worse than you described. You reported a decoy SKU appearing alongside the right one. I downloaded the real S3 offer files (us-west-2 and us-east-1, version
20260728131000) and filteringproductFamily=Storage+volumeType="Glacier Deep Archive"returns only the staging SKU —AGJFYM869JVU9PK4/EXB3YJ6YV5CRH4JN, at"0.0210000000". There is no correct SKU alongside it to pick instead.There is no
TimedStorage-GDA-ByteHrsSKU in the S3 offer file at all. The only0.00099rate anywhere in it isTimedStorage-INT-DAA-ByteHrs— Intelligent-Tiering's Deep Archive Access tier, not Glacier Deep Archive. So that filter is 21× wrong with no correct alternative in view: code that picks "the one result" gets the staging rate and looks like it worked. Both SKUs are in the fixture so you can assert your code reaches the right one, not merely that it produced a plausible number.Two things I confirmed exactly as you reported them: 381 products, 315 missing
productFamily, andTimedStorage-ByteHrscarrying threepriceDimensionswithendRange51200/512000/Inf.One where your table was off:
Requests-Tier1is"0.0000050000", i.e. $0.005 per 1,000. Your table had0.0005, 10× low. The unit isRequests— per-request, not per-thousand — so dividing by 1,000 a second time is a 1,000× error on top.On the two acceptance criteria:
Seedable failure is
POST/DELETE /v1/pricing/query-failures, keyed by operation or"*". Your "pricing degrades, I/O does not" property is only testable if the failure is producible on demand; otherwise the fallback branch is unreachable. The endpoint rejects any code outside the seven the API documents, because a typo'd code would seed an error yourexceptclause never matches — the fallback would go untested while the seed appeared to work.Rejecting non-endpoint regions is
SubstrateInvalidPricingEndpoint(400). Deliberately not an AWS code: real AWS fails DNS resolution before a request is sent, and substrate serves every region from one endpoint so it can't reproduce a name that doesn't resolve. Documented indocs/services.mdas a divergence rather than presented as parity.The region-parsing half you offered to split out shipped separately as #403 → #417, which #418 stacks on. #418 adds the service half:
api.pricing.us-east-1.amazonaws.comhad resolved to a service literally namedapi, so it couldn't route to any plugin. That also unblockedapi.ecr.*andapi.sagemaker.*host-based routing.fix(parser): validate the region parsed from Host and handle api.* ho…
docs: regenerate the service reference after merging main (#401)
feat(pricing): emulate the Price List Query API over a real offer cor…
chore(release): v0.80.0 (#423)