Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paginator error upon failed interaction #2447

Closed
3 tasks done
BobDotCom opened this issue May 10, 2024 · 0 comments · Fixed by #2448
Closed
3 tasks done

Paginator error upon failed interaction #2447

BobDotCom opened this issue May 10, 2024 · 0 comments · Fixed by #2448
Assignees
Labels
bug Something isn't working ext.pages Relating to ext.pages

Comments

@BobDotCom
Copy link
Member

Summary

If a paginator update fails inside callback, the paginator can enter an un-recoverable state

Reproduction Steps

  1. Create a paginator with 2 pages
  2. Click the right arrow/next page button
    • The interaction must fail, you can trigger this by adding a debug breakpoint or a sleep function inside Paginator.goto_page, or by throttling your network connection
  3. Observe the error inside the console: discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
  4. Press the same button again
  5. Observe this error in your console:
    page = self.pages[page_number]
           ~~~~~~~~~~^^^^^^^^^^^^^
IndexError: list index out of range

Minimal Reproducible Code

import os

from discord import Bot
from discord.ext.pages import Paginator
from discord.flags import Intents

bot = Bot(
    intents=Intents.default(),
)


@bot.command()
async def test(ctx):
    paginator = Paginator(
        pages=["page 1", "page 2"],
    )
    await paginator.respond(ctx.interaction)


bot.run(os.getenv("DISCORD_TOKEN"))

Expected Results

The paginator should fallback to its previous state in the event of a failure, so the second update should be a retry of the first.

Actual Results

There is a silent failure, current_page is updated but the paginator is not.

Intents

Intents.default()

System Information

  • Python v3.12.0-final
  • py-cord v2.5.1-final
  • aiohttp v3.9.5
  • system info: Darwin 23.4.0 Darwin Kernel Version 23.4.0: Wed Feb 21 21:44:06 PST 2024; root:xnu-10063.101.15~2/RELEASE_ARM64_T8103

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

@BobDotCom BobDotCom added bug Something isn't working ext.pages Relating to ext.pages labels May 10, 2024
@BobDotCom BobDotCom self-assigned this May 10, 2024
@BobDotCom BobDotCom linked a pull request May 10, 2024 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ext.pages Relating to ext.pages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant