Skip to content

[fix] Return empty array instead of nil from QueryService.getServices#7925

Merged
yurishkuro merged 1 commit intojaegertracing:mainfrom
sujalshah-bit:bug-empty-service-onstart
Feb 3, 2026
Merged

[fix] Return empty array instead of nil from QueryService.getServices#7925
yurishkuro merged 1 commit intojaegertracing:mainfrom
sujalshah-bit:bug-empty-service-onstart

Conversation

@sujalshah-bit
Copy link
Copy Markdown
Contributor

@sujalshah-bit sujalshah-bit commented Jan 27, 2026

Which problem is this PR solving?

Fixes #7921.

Description of the changes

When the backend has no traces, the getServices endpoint returned a nil services field, which is serialized as null in JSON.
This caused the UI to fail validation, since it expects an array.
This change ensures the services field is always returned as an empty array.

How was this change tested?

wrote a test TestQueryServiceGetServicesReturnsEmptySlice in service_test.go.

Checklist

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.56%. Comparing base (435a23d) to head (0532162).
⚠️ Report is 18 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7925   +/-   ##
=======================================
  Coverage   95.56%   95.56%           
=======================================
  Files         316      316           
  Lines       16715    16718    +3     
=======================================
+ Hits        15973    15976    +3     
  Misses        579      579           
  Partials      163      163           
Flag Coverage Δ
badger_v1 9.11% <ø> (ø)
badger_v2 1.90% <ø> (ø)
cassandra-4.x-v1-manual 13.41% <ø> (ø)
cassandra-4.x-v2-auto 1.89% <ø> (ø)
cassandra-4.x-v2-manual 1.89% <ø> (ø)
cassandra-5.x-v1-manual 13.41% <ø> (ø)
cassandra-5.x-v2-auto 1.89% <ø> (ø)
cassandra-5.x-v2-manual 1.89% <ø> (ø)
clickhouse 1.98% <ø> (ø)
elasticsearch-6.x-v1 17.27% <ø> (ø)
elasticsearch-7.x-v1 17.30% <ø> (ø)
elasticsearch-8.x-v1 17.45% <ø> (ø)
elasticsearch-8.x-v2 1.90% <ø> (ø)
elasticsearch-9.x-v2 1.90% <ø> (ø)
grpc_v1 8.44% <ø> (ø)
grpc_v2 1.90% <ø> (ø)
kafka-3.x-v2 1.90% <ø> (ø)
memory_v2 1.90% <ø> (ø)
opensearch-1.x-v1 17.34% <ø> (ø)
opensearch-2.x-v1 17.34% <ø> (ø)
opensearch-2.x-v2 1.90% <ø> (ø)
opensearch-3.x-v2 1.90% <ø> (ø)
query 1.90% <ø> (ø)
tailsampling-processor 0.54% <ø> (ø)
unittests 94.24% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 27, 2026

Metrics Comparison Summary

Total changes across all snapshots: 0

Detailed changes per snapshot

summary_metrics_snapshot_cassandra

📊 Metrics Diff Summary

Total Changes: 0

  • 🆕 Added: 0 metrics
  • ❌ Removed: 0 metrics
  • 🔄 Modified: 0 metrics
  • 🚫 Excluded: 106 metrics

summary_metrics_snapshot_cassandra

📊 Metrics Diff Summary

Total Changes: 0

  • 🆕 Added: 0 metrics
  • ❌ Removed: 0 metrics
  • 🔄 Modified: 0 metrics
  • 🚫 Excluded: 106 metrics

summary_metrics_snapshot_cassandra

📊 Metrics Diff Summary

Total Changes: 0

  • 🆕 Added: 0 metrics
  • ❌ Removed: 0 metrics
  • 🔄 Modified: 0 metrics
  • 🚫 Excluded: 53 metrics

summary_metrics_snapshot_cassandra

📊 Metrics Diff Summary

Total Changes: 0

  • 🆕 Added: 0 metrics
  • ❌ Removed: 0 metrics
  • 🔄 Modified: 0 metrics
  • 🚫 Excluded: 106 metrics

➡️ View full metrics file

@sujalshah-bit sujalshah-bit force-pushed the bug-empty-service-onstart branch from dbcb34c to 1621263 Compare January 27, 2026 10:41
@sujalshah-bit sujalshah-bit marked this pull request as ready for review January 27, 2026 10:42
@sujalshah-bit sujalshah-bit requested a review from a team as a code owner January 27, 2026 10:42
@sujalshah-bit sujalshah-bit force-pushed the bug-empty-service-onstart branch 2 times, most recently from 0937e18 to aae6e51 Compare January 27, 2026 10:56
Some storage backends return nil when no services exist, which caused
the getServices API to omit the services field or serialize it as null.
This breaks the UI schema expectations, which always require an array.

Normalize nil to an empty slice in QueryService.GetServices so that
all callers receive a consistent, non-nil response.

Fixes jaegertracing#7921.

Signed-off-by: Sujal Shah <sujalshah28092004@gmail.com>
@sujalshah-bit sujalshah-bit force-pushed the bug-empty-service-onstart branch from aae6e51 to 0532162 Compare January 27, 2026 11:25
@sujalshah-bit
Copy link
Copy Markdown
Contributor Author

@yurishkuro could you kindly review :)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where the getServices endpoint returns null instead of an empty array when the backend has no traces, which caused validation errors in the UI.

Changes:

  • Modified GetServices method in QueryService to ensure it always returns an empty slice instead of nil
  • Added a test case to verify that GetServices returns an empty slice when the backend returns nil

Reviewed changes

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

File Description
cmd/jaeger/internal/extension/jaegerquery/querysvc/service.go Added nil-safety check to ensure GetServices always returns an empty slice instead of nil
cmd/jaeger/internal/extension/jaegerquery/querysvc/service_test.go Added test case to verify GetServices returns empty slice when backend returns nil
Comments suppressed due to low confidence (1)

cmd/jaeger/internal/extension/jaegerquery/querysvc/service.go:134

  • For consistency with GetServices, consider adding similar nil-safety handling to GetOperations. The v1adapter's GetOperations (at internal/storage/v2/v1adapter/tracereader.go:71) already checks for nil returns, suggesting that some storage backends may return nil for empty results. While not critical for this PR, adding the same defensive check here would prevent similar issues in the future and maintain consistency across the codebase.
func (qs QueryService) GetOperations(
	ctx context.Context,
	query tracestore.OperationQueryParams,
) ([]tracestore.Operation, error) {
	return qs.traceReader.GetOperations(ctx, query)
}

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

@yurishkuro yurishkuro changed the title Fix avoid undefined services field in getServices response [fix] Return empty array instead of nil from QueryService.getServices Feb 3, 2026
@yurishkuro yurishkuro merged commit fefdf18 into jaegertracing:main Feb 3, 2026
66 of 68 checks passed
Parship12 pushed a commit to Parship12/jaeger that referenced this pull request Feb 11, 2026
…jaegertracing#7925)

Fixes jaegertracing#7921.

When the backend has no traces, the getServices endpoint returned a nil
services field, which is serialized as null in JSON.
This caused the UI to fail validation, since it expects an array.
This change ensures the services field is always returned as an empty
array.

wrote a test `TestQueryServiceGetServicesReturnsEmptySlice` in
`service_test.go`.

- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

Signed-off-by: Sujal Shah <sujalshah28092004@gmail.com>
SoumyaRaikwar pushed a commit to SoumyaRaikwar/jaeger that referenced this pull request Feb 13, 2026
…jaegertracing#7925)

## Which problem is this PR solving?

Fixes jaegertracing#7921.

## Description of the changes
When the backend has no traces, the getServices endpoint returned a nil
services field, which is serialized as null in JSON.
This caused the UI to fail validation, since it expects an array.
This change ensures the services field is always returned as an empty
array.

## How was this change tested?
wrote a test `TestQueryServiceGetServicesReturnsEmptySlice` in
`service_test.go`.

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

Signed-off-by: Sujal Shah <sujalshah28092004@gmail.com>
OlegChumin pushed a commit to OlegChumin/jaeger that referenced this pull request Feb 28, 2026
…jaegertracing#7925)

## Which problem is this PR solving?

Fixes jaegertracing#7921.

## Description of the changes
When the backend has no traces, the getServices endpoint returned a nil
services field, which is serialized as null in JSON.
This caused the UI to fail validation, since it expects an array.
This change ensures the services field is always returned as an empty
array.

## How was this change tested?
wrote a test `TestQueryServiceGetServicesReturnsEmptySlice` in
`service_test.go`.

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

Signed-off-by: Sujal Shah <sujalshah28092004@gmail.com>
singhvibhanshu pushed a commit to singhvibhanshu/jaeger that referenced this pull request Mar 18, 2026
…jaegertracing#7925)

## Which problem is this PR solving?

Fixes jaegertracing#7921.

## Description of the changes
When the backend has no traces, the getServices endpoint returned a nil
services field, which is serialized as null in JSON.
This caused the UI to fail validation, since it expects an array.
This change ensures the services field is always returned as an empty
array.

## How was this change tested?
wrote a test `TestQueryServiceGetServicesReturnsEmptySlice` in
`service_test.go`.

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

Signed-off-by: Sujal Shah <sujalshah28092004@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Error when no services returned from the backend

4 participants