You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(search): replace placeholder data returns with Atlas SDK limitation errors (#4)
Replace all placeholder data implementations in search service methods with
proper error messages that inform users about Atlas Admin API limitations.
**Changes Made:**
- Modified `GetSearchAnalyzers()` to return error instead of placeholder data
- Modified `GetSearchFacets()` to return error instead of placeholder data
- Removed helper functions that contained placeholder implementations:
- `extractAnalyzersFromDefinition()`
- `extractFacetsFromDefinition()`
- `analyzeIndexDefinition()`
- Updated error messages to guide users to Atlas UI for unsupported features
**Affected Methods:**
- `GetSearchAnalyzers`: Returns error about SDK not exposing analyzer details
- `GetSearchFacets`: Returns error about SDK not exposing facet details
- `GetSearchMetrics`: Already properly returns limitation error (unchanged)
- `AnalyzeSearchIndex`: Already properly returns limitation error (unchanged)
- `ValidateSearchQuery`: Already properly returns limitation error (unchanged)
**Error Message Pattern:**
All errors now follow consistent format:
1. Structured logging with context (project_id, cluster_name, reason)
2. Clear error message explaining the Atlas SDK limitation
3. Guidance to use Atlas UI for the specific functionality
**Files Modified:**
- `internal/services/atlas/search.go`: Core service method changes (-84 lines)
- `cmd/atlas/search/search.go`: Minor comment updates
- `internal/output/advanced_search.go`: Retained placeholder handling for compatibility
**Breaking Change:** No
**Backward Compatibility:** Yes - methods still exist but now return informative errors
This change prevents users from receiving misleading placeholder data and
provides clear guidance on how to access these features through the Atlas UI.
Refs: Atlas SDK limitation handling
Co-authored-by: Danny Teller <danny.teller@tipalti.com>
// Similar implementation structure as list, but for updating an index
474
-
returnfmt.Errorf("atlas search API not yet available in SDK - see 'matlas atlas search list --help' for alternatives")
473
+
returnfmt.Errorf("search index update operation not supported: Atlas Admin API does not provide index update endpoints. Create a new index with the updated configuration instead")
s.logger.Error("Search analyzer extraction operation not supported by Atlas Admin API",
252
+
"project_id", projectID,
253
+
"cluster_name", clusterName,
254
+
"index_name", indexName,
255
+
"reason", "Atlas SDK does not expose analyzer details from index definitions")
256
256
257
-
returnnil, fmt.Errorf("search index %q not found", indexName)
257
+
returnnil, fmt.Errorf("search analyzer extraction operation not supported: Atlas SDK does not expose analyzer details from index definitions. For analyzer configuration, use the Atlas UI at https://cloud.mongodb.com")
258
258
}
259
259
260
260
// GetSearchFacets retrieves facet configuration for a search index
@@ -263,19 +263,14 @@ func (s *AdvancedSearchService) GetSearchFacets(ctx context.Context, projectID,
263
263
returnnil, fmt.Errorf("projectID, clusterName, and indexName are required")
264
264
}
265
265
266
-
// Get the search index definition to extract facet information
returnnil, fmt.Errorf("failed to list search indexes: %w", err)
270
-
}
266
+
// Log the limitation
267
+
s.logger.Error("Search facet extraction operation not supported by Atlas Admin API",
268
+
"project_id", projectID,
269
+
"cluster_name", clusterName,
270
+
"index_name", indexName,
271
+
"reason", "Atlas SDK does not expose facet details from index definitions")
271
272
272
-
for_, index:=rangeindexes {
273
-
ifindex.GetName() ==indexName {
274
-
returns.extractFacetsFromDefinition(&index), nil
275
-
}
276
-
}
277
-
278
-
returnnil, fmt.Errorf("search index %q not found", indexName)
273
+
returnnil, fmt.Errorf("search facet extraction operation not supported: Atlas SDK does not expose facet details from index definitions. For facet configuration, use the Atlas UI at https://cloud.mongodb.com")
279
274
}
280
275
281
276
// GetSearchMetrics retrieves performance metrics for search indexes
@@ -284,23 +279,13 @@ func (s *AdvancedSearchService) GetSearchMetrics(ctx context.Context, projectID,
284
279
returnnil, fmt.Errorf("projectID and clusterName are required")
285
280
}
286
281
287
-
// Placeholder implementation - would need to call Atlas monitoring APIs
288
-
metrics:=map[string]interface{}{
289
-
"clusterName": clusterName,
290
-
"timeRange": timeRange,
291
-
"metrics": map[string]interface{}{
292
-
"queryCount": "1000",
293
-
"avgQueryTime": "50",
294
-
"indexSize": "2.5GB",
295
-
"errorRate": "0.1%",
296
-
},
297
-
}
298
-
299
-
ifindexName!=nil {
300
-
metrics["indexName"] =*indexName
301
-
}
282
+
// Log the limitation
283
+
s.logger.Error("Search metrics operation not supported by Atlas Admin API",
284
+
"project_id", projectID,
285
+
"cluster_name", clusterName,
286
+
"reason", "Atlas Admin API does not expose real-time metrics endpoints")
302
287
303
-
returnmetrics, nil
288
+
returnnil, fmt.Errorf("search metrics operation not supported: Atlas Admin API does not provide real-time metrics endpoints. For real metrics, use the Atlas UI at https://cloud.mongodb.com")
304
289
}
305
290
306
291
// AnalyzeSearchIndex provides performance analysis for a search index
@@ -309,19 +294,14 @@ func (s *AdvancedSearchService) AnalyzeSearchIndex(ctx context.Context, projectI
309
294
returnnil, fmt.Errorf("projectID, clusterName, and indexName are required")
returnnil, fmt.Errorf("failed to list search indexes: %w", err)
316
-
}
317
-
318
-
for_, index:=rangeindexes {
319
-
ifindex.GetName() ==indexName {
320
-
returns.analyzeIndexDefinition(&index), nil
321
-
}
322
-
}
297
+
// Log the limitation
298
+
s.logger.Error("Search index analysis operation not supported by Atlas Admin API",
299
+
"project_id", projectID,
300
+
"cluster_name", clusterName,
301
+
"index_name", indexName,
302
+
"reason", "Atlas Admin API does not provide index optimization analysis")
323
303
324
-
returnnil, fmt.Errorf("search index %q not found", indexName)
304
+
returnnil, fmt.Errorf("search index analysis operation not supported: Atlas Admin API does not provide optimization analysis endpoints. For real optimization insights, use Atlas Performance Advisor in the Atlas UI")
325
305
}
326
306
327
307
// ValidateSearchQuery validates a search query against an index
@@ -330,21 +310,14 @@ func (s *AdvancedSearchService) ValidateSearchQuery(ctx context.Context, project
330
310
returnnil, fmt.Errorf("projectID, clusterName, and indexName are required")
331
311
}
332
312
333
-
// Placeholder implementation - would need to validate query syntax
334
-
result:=map[string]interface{}{
335
-
"valid": true,
336
-
"errors": []string{},
337
-
"warnings": []string{},
338
-
"query": query,
339
-
}
313
+
// Log the limitation
314
+
s.logger.Error("Search query validation operation not supported by Atlas Admin API",
315
+
"project_id", projectID,
316
+
"cluster_name", clusterName,
317
+
"index_name", indexName,
318
+
"reason", "Atlas Admin API does not provide query validation endpoints")
340
319
341
-
// Basic query validation
342
-
ifquery==nil {
343
-
result["valid"] =false
344
-
result["errors"] = []string{"Query cannot be empty"}
345
-
}
346
-
347
-
returnresult, nil
320
+
returnnil, fmt.Errorf("search query validation operation not supported: Atlas Admin API does not provide query validation endpoints. For real query validation, test queries directly in Atlas UI or MongoDB Compass")
348
321
}
349
322
350
323
// ValidateSearchIndex validates a search index configuration
@@ -378,73 +351,5 @@ func (s *AdvancedSearchService) ValidateSearchIndex(ctx context.Context, project
378
351
returnresult, nil
379
352
}
380
353
381
-
// Helper methods for extracting information from index definitions
0 commit comments