Repository navigation
Live-verify Azure Advisor/Consumption resourceType filter literals (database, synapse, compute, cache, cosmosdb, managedredis) #1318
Description
Activity
- addedtriagedItem has been triagedItem has been triagedpriority/p2Backlog-worthyBacklog-worthyseverity/mediumModerate harmModerate harmurgency/this-quarterWithin the quarterWithin the quarterimpact/fewLimited audienceLimited audienceeffort/mDaysDaystype/bugDefectDefect
on Jun 26, 2026 Reviewed commit:
be11bdcb5. Note:origin/mainmoved to3e9660d06during the review; re-verify against currentmainbefore changing code, since a finding may have been fixed or moved.The 2026-07-28
providers/azurereview re-derived these literals from the SDK rather than by inspection, and the answer resolves most of this issue without a live subscription. Recording it here so it is not re-litigated.Where
- SDK reference:
armconsumption@v1.1.0/models.go:2463-2465 - Current filter sites at
be11bdcb5:compute/client.go:191,cache/client.go:157,managedredis/client.go:41,cosmosdb/client.go:159(via the named constantreservationResourceTypeCosmosDBat:35),database/client.go:189(viareservationResourceTypeSQLDBat:34),synapse/client.go:138(viareservationResourceTypeSynapseat:34) - Purchase-side enum:
armreservations@v1.1.0/constants.go:492-518
What
The
armconsumptionSDK does document the filter's allowedresourceTypevalues, in the model doc comment rather than as a Go enum.models.go:2463-2465lists them verbatim:['VirtualMachines', 'SQLDatabases', 'PostgreSQL', 'ManagedDisk', 'MySQL', 'RedHat', 'MariaDB', 'RedisCache', 'CosmosDB', 'SqlDataWarehouse', 'SUSELinux', 'AppService', 'BlockBlob', ...]Checked against that list, every filter literal in the module today is correct:
Site Literal In the documented list compute/client.go:191VirtualMachinesyes cache/client.go:157,managedredis/client.go:41RedisCacheyes cosmosdb/client.go:159CosmosDByes database/client.go:189SQLDatabasesyes synapse/client.go:138SqlDataWarehouseyes This resolves the three concerns in the issue body, which were written when those sites still carried the older spellings:
databaseno longer uses the singular'SqlDatabase'; it uses the constantreservationResourceTypeSQLDB = "SQLDatabases", which is the documented value.synapseno longer uses'SQLDatabaseDTU'; it usesreservationResourceTypeSynapse = "SqlDataWarehouse", which is the documented value.compute's'VirtualMachines'is the documented value. It is still a hand-typed literal rather than an SDK constant (there is no Go enum for an OData query parameter), but its correctness is now established from the SDK docs.
The casing divergence against the purchase side is correct, not drift. The Capacity Reservations API uses a different, typed enum that spells two of these differently:
CosmosDbandSqlDatabases(armreservations@v1.1.0/constants.go:498,510). Two APIs, two spellings, both right. Any future sweep that "aligns" the Consumption filters with the Capacity enum casing would break the filters.What is still open
Only the purchase-side literals that are genuinely unbacked by an SDK constant:
"SearchService"(search/client.go:257) and the managedredisRedisCacheproduct mismatch. Both are tracked on LeanerCloud/cloud-commitments-go#38 rather than here.Suggested disposition
Narrow this issue to the remaining
armconsumptionvalues that are not on the documented list (none of the six current sites qualify), or close it and let LeanerCloud/cloud-commitments-go#38 carry the live-catalog verification of the purchase-side literals. If it stays open, the recommendation to pin the literals in a namedconstblock per file is already implemented for cosmosdb, database and synapse and could be extended to compute, cache and managedredis, with the SDK doc citation above as the justification comment.
Additional scope note from the CI/test-integrity reviewer, added here so the two halves are not litigated separately:
Recording a verified negative result from the 2026-07-28 full review, so the next reviewer does not re-derive it. Read the scope note at the end carefully: this narrows what remains open here, it does not close this issue.
What was verified: the Consumption reservation-details filter literals are correct
armconsumption@v1.1.0/models.go:2463-2465documents the filter's allowed values verbatim as:['VirtualMachines', 'SQLDatabases', 'PostgreSQL', 'ManagedDisk', 'MySQL', 'RedHat', 'MariaDB', 'RedisCache', 'CosmosDB', 'SqlDataWarehouse', 'SUSELinux', 'AppService', 'BlockBlob', ...]Every filter at these call sites is drawn from that list:
'VirtualMachines'-providers/azure/services/compute/client.go:191'RedisCache'-providers/azure/services/cache/client.go:157,providers/azure/services/managedredis/client.go:41'CosmosDB'-providers/azure/services/cosmosdb/client.go:35'SQLDatabases'-providers/azure/services/database/client.go:34'SqlDataWarehouse'-providers/azure/services/synapse/client.go:34
The purchase side correctly uses the Capacity enum, which spells two of them differently:
CosmosDbandSqlDatabases(armreservations@v1.1.0/constants.go:498,510).So the
CosmosDB/CosmosDbandSQLDatabases/SqlDatabasesdivergences between the two sides are correct, not drift. They look like a copy-paste inconsistency and are not one: the two APIs genuinely use different spellings, and the repo has them right on both sides. Anyone "fixing" the apparent inconsistency by aligning the two spellings would break one of the two call paths.Scope: this does NOT clear the six literals this issue is about
This issue tracks the Advisor / Consumption Recommendations OData filters, which are different call sites at different lines:
database/client.go:174,cache/client.go:175,cosmosdb/client.go:169,compute/client.go:199,synapse/client.go:130,managedredis/client.go:142. Those still need the live verification described here. In particular:database/client.go:174uses'SqlDatabase'(singular), which is not in thearmconsumptionallowed-value list quoted above.synapse/client.go:130uses'SQLDatabaseDTU', which is not in that list either.
Both remain unverified and both are the two this issue flagged as suspicious. Do not close this issue on the strength of the negative result above.
Two literals confirmed as real defects, tracked separately
The same review found the only two purchase-body literals in the module not backed by an SDK constant, filed separately as a MEDIUM in the Azure/GCP slice:
providers/azure/services/search/client.go:257sends a bare"SearchService", which appears in neitherarmreservationsv1.1.0 nor v2.0.0'sReservedResourceTypeenum (constants.go:492-518), and the in-code comment concedes it is unverified.providers/azure/services/managedredis/client.go:274purchases withReservedResourceTypeRedisCache(Azure Cache for Redis) while being surfaced as Azure Managed Redis, a different product.
- SDK reference:
Verified resolved at 3c0f8ac: the two suspicious Consumption filter literals are gone. database now filters on reservationResourceTypeSQLDB = "SQLDatabases" and synapse on reservationResourceTypeSynapse = "SqlDataWarehouse", and every filter value in the six services (VirtualMachines, RedisCache, CosmosDB, SQLDatabases, SqlDataWarehouse) is on the allowed list the armconsumption v1.1.0 SDK documents at models.go:2464. Evidence: providers/azure/services/database/client.go:34,189; synapse/client.go:34,138; cosmosdb/client.go:35,159; compute/client.go:199; cache/client.go:157; managedredis/client.go:41 (#1455 commit 849a76e). Residual axes checked: no live e2e smoke test was added (the SDK-documented list makes it unnecessary for correctness); the managedredis client filtering on RedisCache for a different product is tracked on LeanerCloud/cloud-commitments-go#38. Closing as completed; reopen if the behaviour recurs.
Context
Adversarial review of PR #1208 (ARCH-01) noted that the closing issue #1189 also flagged a related concern: the Advisor /
armconsumptionrecommendation OData filter strings also use hand-typedresourceTypeliterals. The PR explicitly scoped these out (they target a different API surface — Consumption Recommendations, not Capacity Reservations) and the PR description notes they need live verification before being touched.Locations
Concerns
database/client.go:174uses'SqlDatabase'(singular) -- the same value PR fix(providers/azure): send canonical reservedResourceType enum values #1208 fixed on the purchase side from "SqlDatabase" to "SqlDatabases". If the Consumption Recommendations API expects the canonical (plural) form, this filter silently returns zero recommendations for Azure SQL Database. The PR description acknowledges this needs live verification.synapse/client.go:130uses'SQLDatabaseDTU'-- this doesn't match either the purchase enum (SqlDataWarehouse) or any obvious Consumption recommendation category. Suspicious; needs live verification.compute/client.go:199uses'VirtualMachines'while the inbound mapping atproviders/azure/recommendations.go:404lowercases to compare against"virtualmachines". Consistent in case, but the value source is still a literal not derived from the SDK.Recommendation
armconsumptionAPI there is no Go SDK enum for the filterresourceTypevalues (it is an OData query parameter, not a typed field), so the fix is documentation / avarblock at the top of each file naming the live-verified literal, not an SDK constant.GetRecommendationsagainst a live subscription and fails loud if the page count is zero AND zero recommendations were returned — distinguishes "no recommendations available" from "filter is wrong".Out of scope for PR #1208
Per the closing issue #1189 ("Also check the singular 'SqlDatabase' Advisor filter at database/client.go:173") and the PR description ("intentionally left unchanged here; it needs live verification before touching the read path"), this is explicitly deferred.
Surfaced by
PR #1208 adversarial review sweep.