Fix oversized Audio track error messages #6796

Closed
TaakoOfficial wants to merge 1 commit from fix/audio-long-track-errors into V3/develop
TaakoOfficial commented 2026-07-26 03:56:54 +02:00 (Migrated from github.com)

Summary

Fixes Audio track error messages being dropped when Lavalink's error text exceeds Discord's 4,096-character embed description limit.

Long errors are cut to fit and end with [Error truncated due to length.]. Bot owners can find the complete error in spring.log.

Testing

Added tests for errors at the limit and errors that need truncating.

python -m pytest tests/cogs/audio -q (26 passed)

Fixes #6794

## Summary Fixes Audio track error messages being dropped when Lavalink's error text exceeds Discord's 4,096-character embed description limit. Long errors are cut to fit and end with `[Error truncated due to length.]`. Bot owners can find the complete error in `spring.log`. ## Testing Added tests for errors at the limit and errors that need truncating. `python -m pytest tests/cogs/audio -q` (26 passed) Fixes #6794
aikaterna (Migrated from github.com) reviewed 2026-07-26 03:56:54 +02:00
PredaaA (Migrated from github.com) reviewed 2026-07-26 03:56:54 +02:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2026-07-26 04:00:42 +02:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull request overview

This PR updates the Audio cog’s Lavalink event error reporting to avoid Discord rejecting messages when the embed description exceeds Discord’s 4096-character limit, by truncating long errors and optionally attaching the full error as a text file.

Changes:

  • Add _format_track_error() to keep error embed descriptions within Discord’s 4096-character limit while preserving both the beginning and end of long errors.
  • When truncation occurs, attach the full error output as lavalink-track-error.txt via text_to_file.
  • Minor typing/annotation adjustments in lavalink.py.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## Pull request overview This PR updates the Audio cog’s Lavalink event error reporting to avoid Discord rejecting messages when the embed description exceeds Discord’s 4096-character limit, by truncating long errors and optionally attaching the full error as a text file. **Changes:** - Add `_format_track_error()` to keep error embed descriptions within Discord’s 4096-character limit while preserving both the beginning and end of long errors. - When truncation occurs, attach the full error output as `lavalink-track-error.txt` via `text_to_file`. - Minor typing/annotation adjustments in `lavalink.py`. --- 💡 <a href="/Cog-Creators/Red-DiscordBot/new/V3/develop?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-07-26 04:00:42 +02:00

The PR description says new automated coverage was added for short/long errors and the attachment behavior, but there don't appear to be any tests in the repository exercising this code path (no tests reference lavalink_event_handler, Track Error, or lavalink-track-error.txt). Please add the tests described in the PR summary so this truncation/attachment logic stays protected against regressions.

The PR description says new automated coverage was added for short/long errors and the attachment behavior, but there don't appear to be any tests in the repository exercising this code path (no tests reference `lavalink_event_handler`, `Track Error`, or `lavalink-track-error.txt`). Please add the tests described in the PR summary so this truncation/attachment logic stays protected against regressions.
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-07-26 04:00:42 +02:00

The attached lavalink-track-error.txt is built from extra["message"].replace("\n", ""), which removes line breaks from the Lavalink error text. That makes the attachment harder to read and means it isn't the "complete error" as described (it loses original formatting/newlines). Consider keeping the newline-stripped version only for the embed, while attaching the unmodified error text.

The attached `lavalink-track-error.txt` is built from `extra["message"].replace("\n", "")`, which removes line breaks from the Lavalink error text. That makes the attachment harder to read and means it isn't the "complete error" as described (it loses original formatting/newlines). Consider keeping the newline-stripped version only for the embed, while attaching the unmodified error text.
Jackenmen commented 2026-11-12 11:14:18 +01:00 (Migrated from github.com)

The linked issue already has 3 other PRs fixing it, closing.

The linked issue already has 3 other PRs fixing it, closing.
TaakoOfficial commented 2026-11-12 11:15:58 +01:00 (Migrated from github.com)

Was asked to make this one as the once submitted before mine was Slop It was posted in Gen chat. @Jackenmen

https://discord.com/channels/133049272517001216/133081046869737472/1530727543467016233

aikaterna [4EVR],
— Sat 25.07.2026 19:04:45
if there's anyone here in the Red community that doesn't have the Contributor role and would like to, I'd much rather have your interpretation of the answer for https://canary.discord.com/channels/133049272517001216/450749498231357450/1530672986234032332 than the AI-driven, personal rep driven PR we got in response to it so far

Was asked to make this one as the once submitted before mine was Slop It was posted in Gen chat. @Jackenmen https://discord.com/channels/133049272517001216/133081046869737472/1530727543467016233 aikaterna [4EVR], — Sat 25.07.2026 19:04:45 if there's anyone here in the Red community that doesn't have the Contributor role and would like to, I'd much rather have your interpretation of the answer for https://canary.discord.com/channels/133049272517001216/450749498231357450/1530672986234032332 than the AI-driven, personal rep driven PR we got in response to it so far
Jackenmen commented 2026-11-12 11:26:58 +01:00 (Migrated from github.com)

I see. Nonetheless, I'm not a fan of the approach used in this PR - I'd rather have us just truncate it (with clear indication that it was truncated). A regular user won't get much value out of incredibly lengthy errors that would end up going over the length limit and the bot owner can see the whole error in spring.log anyway.
Thank you for the contribution and sorry we couldn't accept it.

I see. Nonetheless, I'm not a fan of the approach used in this PR - I'd rather have us just truncate it (with clear indication that it was truncated). A regular user won't get much value out of incredibly lengthy errors that would end up going over the length limit and the bot owner can see the whole error in spring.log anyway. Thank you for the contribution and sorry we couldn't accept it.
Jackenmen commented 2026-11-12 17:35:50 +01:00 (Migrated from github.com)

I should add that, if you are still interested in contributing, we'd accept a PR that implements it as described in this comment on the original issue:
https://github.com/Cog-Creators/Red-DiscordBot/issues/6794#issuecomment-6821976842

I should add that, if you are still interested in contributing, we'd accept a PR that implements it as described in this comment on the original issue: https://github.com/Cog-Creators/Red-DiscordBot/issues/6794#issuecomment-6821976842

Pull request closed

Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!6796
No description provided.