openclaw - ✅(Solved) Fix Discord delivery reports lastDelivered: true when message actually failed (401 Unauthorized) [1 pull requests, 4 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#49978Fetched 2026-04-08 01:00:35
View on GitHub
Comments
4
Participants
2
Timeline
8
Reactions
0
Timeline (top)
commented ×3cross-referenced ×2mentioned ×1referenced ×1

Discord cron job delivery reports inconsistent state - shows lastDelivered: true but message actually failed with 401 Unauthorized.

Error Message

  • Should trigger error notification/alert "lastRunStatus": "error", Fix the delivery status logic to accurately reflect API response - don't set lastDelivered: true when API returns error.

Root Cause

Discord cron job delivery reports inconsistent state - shows lastDelivered: true but message actually failed with 401 Unauthorized.

Fix Action

Fixed

PR fix notes

PR #5: fix: throw error on Discord delivery failure instead of returning unknown

Description (problem / solution / changelog)

Throw error when Discord API returns empty messageId instead of silently returning unknown. Closes #49978

Changed files

  • src/agents/models-config.providers.discovery.ts (modified, +2/-2)
  • src/daemon/schtasks.ts (modified, +5/-2)
  • src/discord/send.outbound.ts (modified, +4/-1)

Code Example

{
  "lastRunStatus": "error",
  "lastDelivered": true,
  "lastDeliveryStatus": "delivered",
  "lastError": "⚠️ ✉️ Message failed"
}

---

curl: {"message": "401: Unauthorized", "code": 0}
RAW_BUFFERClick to expand / collapse

Description

Discord cron job delivery reports inconsistent state - shows lastDelivered: true but message actually failed with 401 Unauthorized.

Symptoms

  • Cron job ai-daily-brief-discord-mirror shows lastDelivered: true
  • But Discord API returns 401 Unauthorized
  • Message never actually delivered to the channel

Impact

  • User believes message was sent successfully
  • Actual delivery is silent failure
  • No alert or warning triggered

Reproduction

  1. Configure Discord cron job with valid channel ID
  2. Run job (e.g., ai-daily-brief-discord-mirror)
  3. Observe: lastDelivered: true + lastError: "⚠️ ✉️ Message failed"
  4. Verify via Discord API: returns 401 Unauthorized

Expected Behavior

  • When API returns non-2xx, lastDelivered should be false
  • Should trigger error notification/alert
  • Status should reflect actual delivery result

Evidence

{
  "lastRunStatus": "error",
  "lastDelivered": true,
  "lastDeliveryStatus": "delivered",
  "lastError": "⚠️ ✉️ Message failed"
}
curl: {"message": "401: Unauthorized", "code": 0}

Environment

  • OpenClaw version: 2026.3.8
  • Discord channel ID: 1481154074102599781
  • Bot token: valid but API returns 401

Suggestion

Fix the delivery status logic to accurately reflect API response - don't set lastDelivered: true when API returns error.

extent analysis

Fix Plan

To fix the inconsistent state issue, we need to update the delivery status logic to accurately reflect the API response. Here are the steps:

  • Update the ai-daily-brief-discord-mirror cron job to handle API errors correctly:
    • Check the HTTP status code of the API response
    • If the status code is not 2xx, set lastDelivered to false and trigger an error notification/alert
  • Example code snippet (in JavaScript):
const axios = require('axios');

// ...

axios.post(`https://discord.com/api/v10/channels/${channelId}/messages`, {
  // message payload
}, {
  headers: {
    'Authorization': `Bearer ${botToken}`,
    'Content-Type': 'application/json'
  }
})
.then(response => {
  if (response.status >= 200 && response.status < 300) {
    // API request successful, set lastDelivered to true
    lastDelivered = true;
  } else {
    // API request failed, set lastDelivered to false and trigger error notification
    lastDelivered = false;
    triggerErrorNotification();
  }
})
.catch(error => {
  // Handle error
  lastDelivered = false;
  triggerErrorNotification();
});
  • In the above code, triggerErrorNotification() is a function that sends an error notification/alert when the API request fails.

Verification

To verify that the fix worked:

  • Run the ai-daily-brief-discord-mirror cron job
  • Check the lastDelivered status and verify that it reflects the actual delivery result
  • Verify that an error notification/alert is triggered when the API request fails

Extra Tips

  • Make sure to handle all possible error scenarios, including network errors and API rate limits.
  • Consider adding logging to track API request failures and errors.
  • Review the Discord API documentation to ensure that the bot token is valid and has the necessary permissions.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Discord delivery reports lastDelivered: true when message actually failed (401 Unauthorized) [1 pull requests, 4 comments, 2 participants]