Repository navigation
fix: return empty metrics data when no metric queries are built - #168
Merged
Merged
Conversation
CloudWatch GetMetricData rejects a request with an empty MetricDataQueries (400 ValidationError), which surfaced as an error in the Monitoring tab for workspaces with no metrics mappings (e.g. aws/aws-fargate-task). Skip the CloudWatch call and return empty metrics data instead.
ssickles
approved these changes
Aug 28, 2026
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.
Problem
CloudWatch
GetMetricDatarejects a request with an emptyMetricDataQueries:For workspaces with no metrics mappings (e.g.
aws/aws-fargate-task, whosebase_metricsis empty),Getter.GetMetricsbuilt zero queries and sent the request anyway, surfacing in the Nullstone UI Monitoring tab as:Fix
After building queries, if the slice is empty, return
workspace.NewMetricsData(), nilwithout calling CloudWatch — the UI renders an empty/no-metrics state instead of an error.The guard is on the built
queriesrather thanlen(g.Infra.MetricsMappings)becauseoptions.Metricsacts as a filter insideBuildMetricQueries, so non-empty mappings can still produce zero queries.The GCP getter (
gcp/cloudmonitoring) iterates mappings per-series and is naturally safe when empty — no change needed there.Testing
New
TestGetter_GetMetrics_NoQueriescovers both empty mappings and a filter matching nothing; both assert empty metrics data and nil error with no AWS call.go test ./aws/cloudwatch/metrics/passes (run with-mod=mod— the vendor tree is out of sync with go.mod on master, unrelated to this change).