Skip to content

fix(substrate): return 200 with empty result when ate.dev CRDs are not installed#2041

Closed
mesutoezdil wants to merge 6 commits into
kagent-dev:mainfrom
mesutoezdil:fix/substrate-status-no-crd
Closed

fix(substrate): return 200 with empty result when ate.dev CRDs are not installed#2041
mesutoezdil wants to merge 6 commits into
kagent-dev:mainfrom
mesutoezdil:fix/substrate-status-no-crd

Conversation

@mesutoezdil

Copy link
Copy Markdown
Contributor

Closes #2024

listSubstrateCRs calls KubeClient.List on WorkerPoolList and ActorTemplateList unconditionally. When ate.dev CRDs are not installed, the REST mapper returns a NoKindMatchError which propagates as HTTP 500.

Treat meta.IsNoMatchError as an empty result so the endpoint returns 200 with Enabled: false on clusters without agent-substrate.

Adds an optional prometheus.url value. When set, the URL is injected
into the agent system message so the agent knows which endpoint to use.

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
…asourceName

The observability agent queries Prometheus exclusively through the Grafana
MCP tool server. Tools like query_prometheus take a Grafana datasourceUid,
not a raw Prometheus endpoint, so injecting a URL into the system message
provided no actionable value.

Replace prometheus.url with grafana.prometheusDatasourceName. When set,
the agent is told which Grafana datasource to use for all Prometheus
queries, matching how the tools actually work.

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
…by_name with get_datasource

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
…essage

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
Copilot AI review requested due to automatic review settings June 17, 2026 21:13
@github-actions github-actions Bot added the bug Something isn't working label Jun 17, 2026
@mesutoezdil

Copy link
Copy Markdown
Contributor Author

duplicate of #2023

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes /api/substrate/status to avoid returning HTTP 500 when ate.dev CRDs are not installed by treating “no match” REST-mapper errors as an empty result set.

Changes:

  • Handle meta.IsNoMatchError during substrate CR listing so clusters without agent-substrate return a 200 with empty resource lists.
  • Extend the Observability agent Helm chart values/template to optionally pin a Grafana Prometheus datasource name and update the Grafana MCP tool name.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
helm/agents/observability/values.yaml Adds optional grafana.prometheusDatasourceName chart value.
helm/agents/observability/templates/agent.yaml Uses the optional datasource name in the agent prompt and updates Grafana MCP tool list.
go/core/internal/httpserver/handlers/substrate.go Treats meta.IsNoMatchError from Kubernetes list calls as “no substrate installed” instead of a 500.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 112 to 125
wpList := &atev1alpha1.WorkerPoolList{}
if err := h.KubeClient.List(ctx, wpList, listOpts...); err != nil {
if meta.IsNoMatchError(err) {
return nil, nil, nil
}
return nil, nil, err
}
tmplList := &atev1alpha1.ActorTemplateList{}
if err := h.KubeClient.List(ctx, tmplList, listOpts...); err != nil {
if meta.IsNoMatchError(err) {
return nil, nil, nil
}
return nil, nil, err
}
Comment on lines +25 to +29
{{- with .Values.grafana }}{{- if .prometheusDatasourceName }}

## Prometheus Datasource

Before making any Prometheus tool call, you must first call get_datasource with name "{{ .prometheusDatasourceName }}" to resolve the datasource UID. Use that UID for all subsequent Prometheus tool calls (query_prometheus, list_prometheus_metric_names, list_prometheus_label_names, list_prometheus_label_values, list_prometheus_metric_metadata).
Comment on lines 113 to 117
if err := h.KubeClient.List(ctx, wpList, listOpts...); err != nil {
if meta.IsNoMatchError(err) {
return nil, nil, nil
}
return nil, nil, err
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GET /api/substrate/status returns 500 when ate.dev CRDs are not installed

2 participants