Просмотр исходного кода

fix: keep the whole message of long configuration issues

armature-health v2.0.2 cuts issue titles at 512 characters, and the message
was read back from the title. The message is now also kept in the issue
detail, which holds up to 16,000 characters, and read back from there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jamesread 2 дней назад
Родитель
Сommit
8102fbde30
2 измененных файлов с 13 добавлено и 5 удалено
  1. 11 1
      service/internal/configissues/health.go
  2. 2 4
      service/internal/configissues/health_test.go

+ 11 - 1
service/internal/configissues/health.go

@@ -58,6 +58,9 @@ func toHealthIssue(issue Issue) health.Issue {
 		Key:      issueKey(issue),
 		Key:      issueKey(issue),
 		Severity: healthSeverity(issue.Severity),
 		Severity: healthSeverity(issue.Severity),
 		Title:    issue.Message,
 		Title:    issue.Message,
+		// armature-health cuts titles at 512 characters, so the whole message is
+		// also kept in the detail, which holds up to 16,000.
+		Detail: issue.Message,
 		Attributes: map[string]string{
 		Attributes: map[string]string{
 			attrCode:         issue.Code,
 			attrCode:         issue.Code,
 			attrActionID:     issue.ActionID,
 			attrActionID:     issue.ActionID,
@@ -101,7 +104,7 @@ func fromHealthIssue(view health.IssueView) Issue {
 	return Issue{
 	return Issue{
 		Severity:     view.Severity,
 		Severity:     view.Severity,
 		Code:         view.Attributes[attrCode],
 		Code:         view.Attributes[attrCode],
-		Message:      view.Title,
+		Message:      issueMessage(view),
 		ActionID:     view.Attributes[attrActionID],
 		ActionID:     view.Attributes[attrActionID],
 		ActionTitle:  view.Attributes[attrActionTitle],
 		ActionTitle:  view.Attributes[attrActionTitle],
 		ArgumentName: view.Attributes[attrArgumentName],
 		ArgumentName: view.Attributes[attrArgumentName],
@@ -110,6 +113,13 @@ func fromHealthIssue(view health.IssueView) Issue {
 	}
 	}
 }
 }
 
 
+func issueMessage(view health.IssueView) string {
+	if view.Detail == "" {
+		return view.Title
+	}
+	return view.Detail
+}
+
 func rememberOrder(sourceID string, issues []Issue) {
 func rememberOrder(sourceID string, issues []Issue) {
 	positions := make(map[string]int, len(issues))
 	positions := make(map[string]int, len(issues))
 	for index, issue := range issues {
 	for index, issue := range issues {

+ 2 - 4
service/internal/configissues/health_test.go

@@ -184,10 +184,8 @@ func TestLongIssuesKeepOrderAndAreNotLoggedAgain(t *testing.T) {
 
 
 	assert.Len(t, issueLogEntries(hook), 3, "an unchanged long issue must not be logged again")
 	assert.Len(t, issueLogEntries(hook), 3, "an unchanged long issue must not be logged again")
 
 
-	listed := List()
-	require.Len(t, listed, 3)
-	assert.True(t, strings.HasPrefix(listed[1].Message, "b "), "long issues must keep collection order")
-	assert.True(t, strings.HasPrefix(listed[2].Message, "a "), "long issues must keep collection order")
+	runtime := testIssue(CodeDeprecatedAPICall, long)
+	assert.Equal(t, []Issue{runtime, issues[0], issues[1]}, List(), "long issues must keep their whole message and collection order")
 }
 }
 
 
 func TestDuplicateIssueKeepsTheError(t *testing.T) {
 func TestDuplicateIssueKeepsTheError(t *testing.T) {