V14: Return the unhealthy error message from Examine index (#16228)
* Use Attempt<string> result to display the unhealthy error message * Update OpenApi.json * Code readability improvements * Add unittest covering the bug --------- Co-authored-by: Sven Geusens <sge@umbraco.dk>
This commit is contained in:
committed by
GitHub
parent
6577b56d23
commit
53654d3b28
@@ -26,7 +26,10 @@ public class IndexPresentationFactory : IIndexPresentationFactory
|
||||
return new IndexResponseModel
|
||||
{
|
||||
Name = index.Name,
|
||||
HealthStatus = HealthStatus.Rebuilding,
|
||||
HealthStatus = new HealthStatusResponseModel
|
||||
{
|
||||
Status = HealthStatus.Rebuilding,
|
||||
},
|
||||
SearcherName = index.Searcher.Name,
|
||||
DocumentCount = 0,
|
||||
FieldCount = 0,
|
||||
@@ -35,7 +38,7 @@ public class IndexPresentationFactory : IIndexPresentationFactory
|
||||
|
||||
IIndexDiagnostics indexDiag = _indexDiagnosticsFactory.Create(index);
|
||||
|
||||
Attempt<string?> isHealthy = indexDiag.IsHealthy();
|
||||
Attempt<string?> isHealthyAttempt = indexDiag.IsHealthy();
|
||||
|
||||
var properties = new Dictionary<string, object?>();
|
||||
|
||||
@@ -55,7 +58,11 @@ public class IndexPresentationFactory : IIndexPresentationFactory
|
||||
var indexerModel = new IndexResponseModel
|
||||
{
|
||||
Name = index.Name,
|
||||
HealthStatus = isHealthy.Success ? HealthStatus.Healthy : HealthStatus.Unhealthy,
|
||||
HealthStatus = new HealthStatusResponseModel
|
||||
{
|
||||
Status = isHealthyAttempt.Success ? HealthStatus.Healthy : HealthStatus.Unhealthy,
|
||||
Message = isHealthyAttempt.Result,
|
||||
},
|
||||
CanRebuild = _indexRebuilder.CanRebuild(index.Name),
|
||||
SearcherName = index.Searcher.Name,
|
||||
DocumentCount = indexDiag.GetDocumentCount(),
|
||||
|
||||
@@ -32107,6 +32107,115 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Webhook"
|
||||
],
|
||||
"operationId": "DeleteWebhookById",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "uuid"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"headers": {
|
||||
"Umb-Notifications": {
|
||||
"description": "The list of notifications produced during the request.",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/NotificationHeaderModel"
|
||||
},
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"headers": {
|
||||
"Umb-Notifications": {
|
||||
"description": "The list of notifications produced during the request.",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/NotificationHeaderModel"
|
||||
},
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"200": {
|
||||
"description": "Success",
|
||||
"headers": {
|
||||
"Umb-Notifications": {
|
||||
"description": "The list of notifications produced during the request.",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/NotificationHeaderModel"
|
||||
},
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "The resource is protected and requires an authentication token"
|
||||
},
|
||||
"403": {
|
||||
"description": "The authenticated user do not have access to this resource",
|
||||
"headers": {
|
||||
"Umb-Notifications": {
|
||||
"description": "The list of notifications produced during the request.",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/NotificationHeaderModel"
|
||||
},
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Backoffice User": [ ]
|
||||
}
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"tags": [
|
||||
"Webhook"
|
||||
@@ -32246,115 +32355,6 @@
|
||||
"Backoffice User": [ ]
|
||||
}
|
||||
]
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Webhook"
|
||||
],
|
||||
"operationId": "DeleteWebhookById",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "uuid"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"headers": {
|
||||
"Umb-Notifications": {
|
||||
"description": "The list of notifications produced during the request.",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/NotificationHeaderModel"
|
||||
},
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"headers": {
|
||||
"Umb-Notifications": {
|
||||
"description": "The list of notifications produced during the request.",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/NotificationHeaderModel"
|
||||
},
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"200": {
|
||||
"description": "Success",
|
||||
"headers": {
|
||||
"Umb-Notifications": {
|
||||
"description": "The list of notifications produced during the request.",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/NotificationHeaderModel"
|
||||
},
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "The resource is protected and requires an authentication token"
|
||||
},
|
||||
"403": {
|
||||
"description": "The authenticated user do not have access to this resource",
|
||||
"headers": {
|
||||
"Umb-Notifications": {
|
||||
"description": "The list of notifications produced during the request.",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/NotificationHeaderModel"
|
||||
},
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Backoffice User": [ ]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/umbraco/management/api/v1/webhook/events": {
|
||||
@@ -36671,6 +36671,22 @@
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"HealthStatusResponseModel": {
|
||||
"required": [
|
||||
"status"
|
||||
],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"status": {
|
||||
"$ref": "#/components/schemas/HealthStatusModel"
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"HelpPageResponseModel": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -36733,7 +36749,11 @@
|
||||
"type": "string"
|
||||
},
|
||||
"healthStatus": {
|
||||
"$ref": "#/components/schemas/HealthStatusModel"
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/HealthStatusResponseModel"
|
||||
}
|
||||
]
|
||||
},
|
||||
"canRebuild": {
|
||||
"type": "boolean"
|
||||
@@ -43456,11 +43476,12 @@
|
||||
"UserGroupResponseModel": {
|
||||
"required": [
|
||||
"alias",
|
||||
"aliasCanBeChanged",
|
||||
"documentRootAccess",
|
||||
"fallbackPermissions",
|
||||
"hasAccessToAllLanguages",
|
||||
"id",
|
||||
"isSystemGroup",
|
||||
"isDeletable",
|
||||
"languages",
|
||||
"mediaRootAccess",
|
||||
"name",
|
||||
@@ -43541,7 +43562,10 @@
|
||||
"type": "string",
|
||||
"format": "uuid"
|
||||
},
|
||||
"isSystemGroup": {
|
||||
"isDeletable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"aliasCanBeChanged": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
@@ -44041,4 +44065,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Umbraco.Cms.Api.Management.ViewModels.Indexer;
|
||||
|
||||
public class HealthStatusResponseModel
|
||||
{
|
||||
public HealthStatus Status { get; init; }
|
||||
|
||||
public string? Message { get; init; }
|
||||
}
|
||||
@@ -7,7 +7,7 @@ public class IndexResponseModel
|
||||
[Required]
|
||||
public string Name { get; init; } = null!;
|
||||
|
||||
public HealthStatus HealthStatus { get; init; }
|
||||
public HealthStatusResponseModel HealthStatus { get; set; } = new();
|
||||
|
||||
[Required]
|
||||
public bool CanRebuild { get; init; }
|
||||
|
||||
Reference in New Issue
Block a user