Repository navigation
fix(aws-cloudwatch): DashboardNotFoundError shape, FILL/IF/SEARCH metric math, non-goals - #1537
Open
Satyam-Trivedi-ZS wants to merge 4 commits into
Open
Satyam-Trivedi-ZS wants to merge 4 commits into
Satyam-Trivedi-ZS wants to merge 4 commits into
Conversation
…dashboards GetDashboard and DeleteDashboards list DashboardNotFoundError (awsQuery code ResourceNotFound, HTTP 404) in the CloudWatch model. The rpc-v2-cbor and JSON codecs wrote __type ResourceNotFound, so aws-sdk-go-v2 fell back to a generic API error instead of types.DashboardNotFoundError. Write the shape name in __type and the query code in X-Amzn-Query-Error; the query/XML code stays ResourceNotFound, which is already correct. Part of stackshy#1520 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ors in metric math
FILL, IF and SEARCH were stored but parsed as unsupported, so GetMetricData
and metric-math alarms returned no data for them. Implement them following
the CloudWatch user guide (Use metric math, search expression syntax):
- comparison (== != < <= > >=) and logical (AND/&&, OR/||) operators, with a
point missing from one series read as 0
- IF(cond, a[, b]) with the documented per-point rules and tables
- FILL(x, S|TS|REPEAT|LINEAR) over the periods of the query range
- SEARCH(' {schema} term ', 'Stat'[, period]) over metrics with data in the
past two weeks; each found metric is its own GetMetricData result row
Part of stackshy#1520
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…-goals GetMetricWidgetImage renders a PNG graph, which the emulator does not do. Record it, the metric math functions that are evaluated, the labels the AWS docs leave unstated, and the newer AnomalyDetectorId surface as non-goals. Part of stackshy#1520 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Pointer params for the 96-byte result, operator and keyword constants, smaller parser and search lexer functions, and drop the nolint:dupl on deleteMetricStream that the dashboard change made unused. Part of stackshy#1520 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Part of #1520 (AWS CloudWatch real-cloud parity gaps).
types.DashboardNotFoundErrorin the SDK (rpc-v2-cbor and JSON).FILL,IF,SEARCH, and the comparison and logical operators. Before, these returned no data.GetMetricWidgetImageand the newerAnomalyDetectorIdsurface are written up as non-goals.Per-item status
DashboardNotFoundError. That is the shape name. Its wire code isResourceNotFoundwith HTTP 404 (botocorecloudwatch/2010-08-01/service-2.json:DashboardNotFoundError.error = {code: ResourceNotFound, httpStatusCode: 404}; the GetDashboard API reference listsResourceNotFound, 404). The query/XML code was already correct. The actual gap was in rpc-v2-cbor and JSON: they put__type: ResourceNotFound, but aws-sdk-go-v2 cloudwatch v1.56.2 matches the shape name (case "DashboardNotFoundError"indeserializers.go), soerrors.Asnever foundtypes.DashboardNotFoundError.ANOMALY_DETECTION_BAND(m1[,k])already returned the lower and upper rows (server/aws/cloudwatch/core_metric_data.gometricDataRows, testTestGetMetricDataAnomalyBandinanomaly_detectors_test.go). FILL, IF and SEARCH failed to parse, so they returned no data.docs/coverage/nongoals/monitoring.md.GetMetricWidgetImageOutput.MetricWidgetImage, base64 PNG). That is presentation output, not control-plane state, and cloudemu has no renderer. Returning a fake image would mislead callers, so it is recorded as a non-goal indocs/coverage/nongoals/monitoring.mdinstead.Changes
Dashboard errors (
server/aws/cloudwatch, wire translation only):wireErrorgets an optionalshape.dashboardErrturns a store NotFound into codeResourceNotFound, shapeDashboardNotFoundError, status 404.__typeandResourceNotFound;SenderinX-Amzn-Query-Error, the way an awsQueryCompatible service does.ErrorCode()therefore staysResourceNotFound, and the CLI still showsResourceNotFound.Metric math (
services/monitoring/metricmath). Onlyproviders/aws/cloudwatchandserver/aws/cloudwatchimport this package; there is no Azure/GCP consumer. Semantics come from Use metric math and the search expression syntax / examples:== != < <= > >=and logical operatorsAND/&&,OR/||. When a timestamp exists in only one series, the other series counts as 0 there, as the doc's table shows.IF(cond, a[, b])follows the documented per-point rules. All three IF tables from the guide are unit-tested verbatim.FILL(x, S | TS | REPEAT | LINEAR)fills the periods of the query range[StartTime, EndTime), aligned the same way as the metric reads.FILL(TS[], ...)works over SEARCH results.SEARCH(' {Namespace,Dim...} term ', 'Stat'[, period])covers:"..."matching,Name=valuedesignators, andAND/OR/NOTwith parenthesesWithRange,WithSearchandResolveAll. The provider's math alarms and anomaly-detector state also pass the range, so FILL works in alarms.Docs: new
docs/coverage/nongoals/monitoring.md, plus the regenerateddocs/coverage(go generate ./...). No driver interface changed.Provider Coverage
Checklist
go test ./...)upstream/development, and this branch removes onedupl(details below).cloudemu_test.go— covered by aws-sdk-go-v2 wire tests inserver/aws/cloudwatchgo generate ./...) and committed the resultTest Plan
Fail-before / pass-after (verified by running the new tests against the pre-fix sources):
TestSDKDashboardNotFoundShape(aws-sdk-go-v2). Before the fix:error *smithy.OperationError ... is not *types.DashboardNotFoundError. After:errors.Assucceeds,ErrorCode()=="ResourceNotFound", HTTP 404, and a failedDeleteDashboardsleaves the other named dashboard in place.TestSDKGetMetricDataFILLAndIFandTestSDKGetMetricDataSEARCH(aws-sdk-go-v2). Before the fix every row was empty (zero values = [], want [0 10 0 30 0]...). After, the rows match the documented values.services/monitoring/metricmath/functions_test.go:TestIFExpressions(the guide's tables),TestComparisonAndLogicalOperators(the guide's operator table),TestFILL*,TestSEARCH(the tokenization and partial/exact cases from the syntax page),TestSEARCHReadsEachMetric,TestFILLOverSEARCH,TestFunctionReferences.TestJSONProtocolErrorsnow expects__type: DashboardNotFoundErrorwithX-Amzn-Query-Error: ResourceNotFound;Sender.TestReferences,TestMathAlarmUnsupportedExpression). They now useRATE, which is still unsupported.Checks run:
go build ./...go veton the touched packagesgo test -p 2 ./...(full). One run passed with exit 0. A later run on a 98%-full disk failed to build ~50 untouchedserver/azure/*packages andTestK8sDataPlanePersistsAcrossCrash. All of them pass when re-run (go test -p 2 ./server/azure/...,go test -run TestK8sDataPlanePersistsAcrossCrash ./cmd/cloudemu), so these were environmental.golangci-lint run --timeout=15m --concurrency 2 ./...: the repo-wide run reports about 400 pre-existing findings in untouched services, the same asupstream/development(CI runs lint as advisory). On the touched packages (./services/monitoring/... ./server/aws/cloudwatch/... ./providers/aws/cloudwatch/..., uncapped):upstream/developmentworktree reports the same 10, plus 1dupl(dashboards.go vs metric_streams.go) that this branch removesReal-user test:
cloudemu serve -aws-port 4610 ...(in the background) driven with AWS CLI v1 (botocore 1.42.97), with--endpoint-url http://127.0.0.1:4610 --region us-east-1:Known limits (documented in the non-goals file):
FILLwithREPEAT/LINEARleaves the edge gaps empty.SUM,METRICS,RATE, ...) still return no data.Related Issues
Part of #1520
🤖 Generated with Claude Code