Skip to content

Comments

fix: resolve "no query support for metric type" error in external API#1708

Open
Bre77 wants to merge 3 commits intohyperdxio:mainfrom
Bre77:fix/metrics-api-field-as-metric-name
Open

fix: resolve "no query support for metric type" error in external API#1708
Bre77 wants to merge 3 commits intohyperdxio:mainfrom
Bre77:fix/metrics-api-field-as-metric-name

Conversation

@Bre77
Copy link

@Bre77 Bre77 commented Feb 6, 2026

Summary

  • Fix external API POST /api/v2/charts/series returning "no query support for metric type=gauge" when field is passed without metricName
  • When querying metric sources, the API now falls back to using field as the metricName and defaults valueExpression to 'Value' (the ClickHouse column), matching how the dashboard UI builds chart configs
  • Backward compatible: when both metricName and field are provided, behavior is unchanged

Root Cause

buildChartConfigFromRequest() mapped field to valueExpression but never populated metricName from it. Downstream, translateMetricChartConfig() requires both metricType AND metricName to be truthy — when metricName was undefined, it fell through to the catch-all error.

Test plan

  • Added integration tests for gauge, sum, and histogram metrics using field without metricName
  • Verify existing metric tests still pass (backward compatible — passing both metricName and field works as before)
  • Verify non-metric source queries are unaffected

Related: #1418, #1214

🤖 Generated with Claude Code

@vercel
Copy link

vercel bot commented Feb 6, 2026

@Bre77 is attempting to deploy a commit to the HyperDX Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link

changeset-bot bot commented Feb 6, 2026

🦋 Changeset detected

Latest commit: b946049

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/api Patch
@hyperdx/app Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@MikeShi42 MikeShi42 requested a review from knudtty February 17, 2026 08:02
@pulpdrew pulpdrew self-requested a review February 19, 2026 15:07
Copy link
Contributor

@pulpdrew pulpdrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Two minor comments but overall LGTM.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 21, 2026

PR Review

✅ No critical issues found.

Logic is correct:

  • resolvedMetricName = metricName ?? field properly falls back for metric sources
  • resolvedValueExpression correctly defaults to 'Value' (ClickHouse column) when only field is used as metric name, and uses field as valueExpression only when both are explicitly provided
  • All edge cases covered: field-only, metricName-only, both, neither

Validation is fine:

  • field uses the same z.string().optional() schema as metricName — no new attack surface introduced

Test coverage is solid (gauge, sum, histogram, and backward-compat). Changeset included. Good to merge.

🤖 Generated with Claude Code

Bre77 and others added 3 commits February 21, 2026 14:19
When querying metrics via POST /api/v2/charts/series, passing the metric
name as `field` without also setting `metricName` caused the query to
fail because translateMetricChartConfig() requires metricName to be set.

Now the external API falls back to using `field` as the metric name when
`metricName` is not provided, and defaults valueExpression to 'Value'
(the ClickHouse column), matching how the dashboard UI builds configs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add test verifying metricName takes precedence over field when both
are provided, and fix lint formatting in ternary expressions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Bre77 Bre77 force-pushed the fix/metrics-api-field-as-metric-name branch from e7c2c49 to b946049 Compare February 21, 2026 04:19
@Bre77 Bre77 requested a review from pulpdrew February 21, 2026 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants