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

Don't upload to pastebin when no truncation #3046

Merged
merged 3 commits into from
May 23, 2024
Merged

Conversation

vivekashok1221
Copy link
Member

@vivekashok1221 vivekashok1221 commented May 12, 2024

Closes issue #2492

(PR description ripped from #3045)
If the output generated by snekbox has 11 lines, the output sent to Discord as well as the contents uploaded to our pastebin is the exact same.
image
image

This is because we always truncate the output to 11 lines, but we check if the number of lines is more than 10 to decide if we need upload to the pastebin. Basically, the current logic for deciding if the output is uploaded to pastebin or not relies on the extra 11th line of output. This works when the output has 12 lines or more (11 lines displayed, full output sent to pastebin), or if it the output has 10 lines or less. But when it is 11, the 11th line is included in the output as well as uploaded to the pastebin (we truncate to 11 lines but upload to the pastebin if the output has more than 10 lines). I'd say this is because of the incorrect fix for #709 but don't quote me on that.

Another thing I noticed is that we display 11 lines in Discord when MAX_OUTPUT_BLOCK_LINES is 10. I initially thought this was introduced in this commit when we switched from str.split("\n") to str.splitlines() but it seems like ever since we started truncating eval output, we've been displaying 11 lines. If we indeed intend to display 11 lines of output, we should consider updating MAX_OUTPUT_BLOCK_LINES. In this PR, I've truncated the output to 10 lines

New behaviour:
image
image

@vivekashok1221 vivekashok1221 linked an issue May 12, 2024 that may be closed by this pull request
@Xithrius Xithrius added p: 2 - normal Normal Priority a: utility Related to utility commands: (bot, eval, extensions, jams, reminders, snekbox, utils) s: needs review Author is waiting for someone to review and approve t: bug Something isn't working a: frontend Related to output and formatting labels May 13, 2024
Copy link
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're adding a line to say that the message was truncated, but we're only truncating one line, wouldn't it be better to not truncate and the result would be the same number of lines?

That's the proposal I put forward here #2498 (comment), essentially, for max_lines=10:

  • 9 lines: not truncated
  • 10 lines: not truncated
  • 11 lines: truncated to 9 lines, plus the truncation message.

This is already an improvement though, i'm happy to approve if you'd rather leave it like this.

Copy link
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks!

@wookie184 wookie184 enabled auto-merge May 23, 2024 15:59
@wookie184 wookie184 merged commit f644d78 into main May 23, 2024
4 checks passed
@wookie184 wookie184 deleted the vivek/fix-eval-truncation branch May 23, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: frontend Related to output and formatting a: utility Related to utility commands: (bot, eval, extensions, jams, reminders, snekbox, utils) p: 2 - normal Normal Priority s: needs review Author is waiting for someone to review and approve t: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Eval output allows too many lines
4 participants