Skip to content

Commit 51a0af1

Browse files
authored
Fix 500 error when no artifacts match the filters in hardware configuration table (#2095)
Signed-off-by: manaswinidas <[email protected]>
1 parent b93c474 commit 51a0af1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

catalog/internal/db/models/performance_artifact_service.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,13 @@ func (s *PerformanceArtifactService) generateRecommendations(artifacts []Catalog
250250
}
251251

252252
// validateCustomProperties ensures at least one artifact contains each custom property
253+
// When there are no artifacts, validation passes (empty result is valid)
253254
func (s *PerformanceArtifactService) validateCustomProperties(artifacts []CatalogMetricsArtifact, rpsProperty, latencyProperty, hardwareCountProperty, hardwareTypeProperty string) error {
255+
// If there are no artifacts, validation passes - empty result is valid
256+
if len(artifacts) == 0 {
257+
return nil
258+
}
259+
254260
propertyExists := map[string]bool{
255261
rpsProperty: false,
256262
latencyProperty: false,

catalog/internal/db/models/performance_artifact_service_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ func TestPerformanceArtifactService_Recommendataions(t *testing.T) {
208208
func TestPropertyValidation(t *testing.T) {
209209
service := NewPerformanceArtifactService(nil)
210210

211+
// Test case: empty artifacts should pass validation (not an error condition)
212+
err := service.validateCustomProperties([]CatalogMetricsArtifact{}, "rps", "latency", "hw_count", "hw_type")
213+
require.NoError(t, err, "Empty artifacts should not cause validation error")
214+
211215
// Test case: property exists in some artifacts
212216
id1 := int32(1)
213217
id2 := int32(2)
@@ -238,7 +242,7 @@ func TestPropertyValidation(t *testing.T) {
238242
artifacts[1].SetID(id2)
239243

240244
// Should not error when property exists in at least one artifact
241-
err := service.validateCustomProperties(artifacts, "custom_rps", "custom_latency", "custom_hw_count", "custom_hw_type")
245+
err = service.validateCustomProperties(artifacts, "custom_rps", "custom_latency", "custom_hw_count", "custom_hw_type")
242246
require.NoError(t, err)
243247

244248
// Test case: property doesn't exist in any artifact

0 commit comments

Comments
 (0)