mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-11-10 21:32:43 +08:00
fix(channels): truncate Telegram and Discord upstream error bodies to 200 bytes (#22075)
This commit is contained in:
2 files changed
+4
-4
No files matched your search
@@ -624,7 +624,7 @@ func (c *discordChannel) requestJSON(ctx context.Context, method, path string, b
|
||||
if resp.StatusCode == http.StatusTooManyRequests {
|
||||
return newDiscordRateLimitError(resp.Header, respBody)
|
||||
}
|
||||
return fmt.Errorf("discord api status: %d, response: %s", resp.StatusCode, string(respBody))
|
||||
return fmt.Errorf("discord api status: %d, response: %.200s", resp.StatusCode, respBody)
|
||||
}
|
||||
if out != nil && len(bytes.TrimSpace(respBody)) > 0 {
|
||||
return json.Unmarshal(respBody, out)
|
||||
@@ -649,7 +649,7 @@ func newDiscordRateLimitError(header http.Header, body []byte) *discordRateLimit
|
||||
return &discordRateLimitError{
|
||||
RetryAfter: retryAfter,
|
||||
Global: payload.Global,
|
||||
Response: strings.TrimSpace(string(body)),
|
||||
Response: fmt.Sprintf("%.200s", strings.TrimSpace(string(body))),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -380,7 +380,7 @@ func (c *telegramChannel) callAPI(ctx context.Context, method string, params map
|
||||
return err
|
||||
}
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
return fmt.Errorf("Telegram API %s returned status %d: %s", method, resp.StatusCode, string(body))
|
||||
return fmt.Errorf("Telegram API %s returned status %d: %.200s", method, resp.StatusCode, body)
|
||||
}
|
||||
|
||||
var response telegramAPIResponse
|
||||
@@ -388,7 +388,7 @@ func (c *telegramChannel) callAPI(ctx context.Context, method string, params map
|
||||
return fmt.Errorf("Telegram API %s returned invalid JSON: %w", method, err)
|
||||
}
|
||||
if !response.OK {
|
||||
return fmt.Errorf("Telegram API %s failed: %s", method, response.Description)
|
||||
return fmt.Errorf("Telegram API %s failed: %.200s", method, response.Description)
|
||||
}
|
||||
if out != nil && len(response.Result) > 0 {
|
||||
if err := json.Unmarshal(response.Result, out); err != nil {
|
||||
|
||||
Reference in new issue
Block a user