Repository navigation
fix: filter deleted providers out of /api/provider-metrics topology (#10714) - #10742
Merged
diegosouzapw merged 1 commit intoAug 19, 2026
Merged
Conversation
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…heaper-inference#10714) (cheaper-inference#10742) Co-authored-by: Markus Hartung <mail@hartmark.se>
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.
Closes #10714
Root cause
getProviderMetrics()(src/lib/db/callLogStats.ts) aggregates/api/provider-metricstopology data directly fromcall_logsgrouped by provider, with no filter against currently-liveprovider_connections. Deleting a provider connection (src/lib/db/providers/deletion.ts) never touchescall_logs, so a deleted provider's historical rows keep feeding the Home "Provider Topology" widget forever — including a permanent stale "error" node if its last logged status was non-2xx.Fix
Add
AND EXISTS (SELECT 1 FROM provider_connections pc WHERE pc.provider = c.provider)to thegetProviderMetrics()query, so only providers with a live connection row surface in topology/metrics. Read-only aggregation query change; sole caller is/api/provider-metrics(the similarly-named MCPhandleGetProviderMetricsis an unrelated function hitting different endpoints).Regression test (TDD, Hard Rule #18)
tests/unit/provider-metrics-deleted-provider.test.ts— seeds a liveopenaiconnection + call log, and ag4f-pollinationscall log with no matchingprovider_connectionsrow (simulating a deleted provider). Asserts the deleted provider never appears intopology.providers,metrics, ortopology.errorProvider, while the live provider still does.AssertionError: deleted provider must not appear in topology.providers — true !== falsetests 1, pass 1, fail 0Also updated fixtures in the two existing suites that exercise this query (
tests/unit/provider-metrics-route.test.ts,tests/unit/db-call-log-stats-3500.test.ts) to seedprovider_connectionsrows for the providers they assert on — required setup under the new filter, not a weakened assertion.Gates run (all clean on touched files)
node scripts/check/check-file-size.mjs— OKnode scripts/check/check-complexity.mjs— OK (2546 violations vs baseline 2774)node scripts/check/check-cognitive-complexity.mjs— OK (1144 violations vs baseline 1223)node scripts/check/check-changelog-integrity.mjs— OKnpx eslint --suppressions-location config/quality/eslint-suppressions.json <touched files>— cleannpm run typecheck:core— exit 0