Skip to content

Commit 4ccadcf

Browse files
authored
Merge pull request #46 from blockopsnetwork/chore/update-error-messages
Update error messages
2 parents d5cf1a7 + a6d8ef4 commit 4ccadcf

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

cmd/bot.go

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ func NewBot(cfg *config.Config, logger *slog.Logger, slackClient *slack.Client,
6767
if cfg.APIKey != "" {
6868
go func() {
6969
if err := bot.syncConfigToAgentCore(); err != nil {
70-
if strings.Contains(err.Error(), "authentication failed") {
71-
logger.Error("Failed to sync configuration to agent-core: Authentication failed. Check your API key in ponos.yml", "error", err)
72-
} else {
73-
logger.Error("Failed to sync configuration to agent-core", "error", err)
74-
}
70+
if strings.Contains(err.Error(), "authentication failed") {
71+
logger.Error("Failed to sync configuration to Nodeoperator API: Authentication failed. Check your API key in ponos.yml", "error", err)
7572
} else {
76-
logger.Info("Configuration synced to agent-core successfully")
73+
logger.Error("Failed to sync configuration to Nodeoperator API", "error", err)
7774
}
78-
}()
75+
} else {
76+
logger.Info("Configuration synced to Nodeoperator API successfully")
77+
}
78+
}()
7979
}
8080

8181
return bot
@@ -478,9 +478,8 @@ func (b *Bot) streamAgentResponseToSlack(event *slackevents.AppMentionEvent, use
478478
ack := fmt.Sprintf(":wave: <@%s> working on \"%s\" …", userID, userMessage)
479479
b.postThreadedSlackMessage(channel, threadTS, ack)
480480

481-
// Check if agent-core URL is configured
482481
if b.agentCoreURL == "" {
483-
b.postThreadedSlackMessage(channel, threadTS, ":x: Agent service is not available. Please check if agent-core is running.")
482+
b.postThreadedSlackMessage(channel, threadTS, ":x: Nodeoperator API is not available. Please check its status and URL.")
484483
return
485484
}
486485

@@ -549,7 +548,6 @@ func (b *Bot) streamAgentResponseToSlack(event *slackevents.AppMentionEvent, use
549548
finalResponse = "Done! Let me know if you need anything else."
550549
}
551550

552-
// Only show tool summary if there are meaningful results and not too many
553551
if len(toolSummaries) > 0 && len(toolSummaries) <= 5 {
554552
finalResponse = fmt.Sprintf("%s\n\n*Tool summary:*\n%s", finalResponse, strings.Join(toolSummaries, "\n"))
555553
} else if len(toolSummaries) > 5 {
@@ -628,7 +626,7 @@ func (b *Bot) doJSON(ctx context.Context, method, url string, in any, out any) e
628626
if resp.StatusCode != http.StatusOK {
629627
body, _ := io.ReadAll(io.LimitReader(resp.Body, 4096))
630628
if resp.StatusCode == http.StatusUnauthorized {
631-
return fmt.Errorf("authentication failed: invalid or missing API key for agent-core (HTTP 401)")
629+
return fmt.Errorf("authentication failed: missing or invalid API key. Get one at https://platform.nodeoperator.ai/ and set api_key in ponos.yml")
632630
}
633631
return fmt.Errorf("HTTP %d: %s", resp.StatusCode, strings.TrimSpace(string(body)))
634632
}
@@ -818,11 +816,11 @@ func (b *Bot) ProcessReleaseUpdate(ctx context.Context, payload ReleasesWebhookP
818816
url := fmt.Sprintf("%s/blockchain/analyze-release", b.agentCoreURL)
819817
var result AgentSummary
820818
if err := b.doJSON(ctx, "POST", url, request, &result); err != nil {
821-
return nil, fmt.Errorf("agent-core request failed: %w", err)
819+
return nil, fmt.Errorf("Nodeoperator API request failed: %w", err)
822820
}
823821

824822
if !result.Success {
825-
return nil, fmt.Errorf("agent-core analysis failed: %s", result.Error)
823+
return nil, fmt.Errorf("Nodeoperator API analysis failed: %s", result.Error)
826824
}
827825

828826
return &result, nil
@@ -849,15 +847,14 @@ If no blockchain containers found, return: []`, yamlContent)
849847
url := fmt.Sprintf("%s/agent/simple", b.agentCoreURL)
850848
var response map[string]any
851849
if err := b.doJSON(ctx, "POST", url, request, &response); err != nil {
852-
return nil, fmt.Errorf("agent-core request failed: %w", err)
850+
return nil, fmt.Errorf("Nodeoperator API request failed: %w", err)
853851
}
854852

855853
content, ok := response["content"].(string)
856854
if !ok {
857-
return nil, fmt.Errorf("invalid response format from agent-core")
855+
return nil, fmt.Errorf("invalid response format from Nodeoperator API")
858856
}
859857

860-
// Parse JSON array from response
861858
var repos []string
862859
if err := b.extractAndUnmarshalJSON(content, &repos); err != nil {
863860
b.logger.Warn("Failed to parse YAML analysis response", "error", err, "response", content)
@@ -913,7 +910,7 @@ func (b *Bot) StreamConversation(ctx context.Context, userMessage string, conver
913910
if resp.StatusCode != http.StatusOK {
914911
body, _ := io.ReadAll(io.LimitReader(resp.Body, 4096))
915912
if resp.StatusCode == http.StatusUnauthorized {
916-
return fmt.Errorf("authentication failed: invalid or missing API key for agent-core (HTTP 401)")
913+
return fmt.Errorf("authentication failed: missing or invalid API key. Get one at https://platform.nodeoperator.ai/ and set api_key in ponos.yml")
917914
}
918915
return fmt.Errorf("HTTP %d: %s", resp.StatusCode, string(body))
919916
}
@@ -1019,7 +1016,7 @@ func (b *Bot) processStreamingResponse(body io.Reader, updates chan<- StreamingU
10191016
CheckpointID: checkpointID,
10201017
}
10211018
case "error":
1022-
return fmt.Errorf("agent-core error: %s", message)
1019+
return fmt.Errorf("Nodeoperator API error: %s", message)
10231020
}
10241021
}
10251022

0 commit comments

Comments
 (0)