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

fix: truncate long action messages to avoid overflow #2773

Merged
merged 4 commits into from
May 17, 2024

Conversation

gabrielgiroe1
Copy link
Collaborator

@gabrielgiroe1 gabrielgiroe1 commented May 16, 2024

Description

Implement message truncation to 320 characters on action.

Fixes #2707

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Screenshots & recording

Manual review steps

  1. Step 1
  2. Step 2

Manual reviewer: please leave a comment with output from the test if that's the case.

Copy link

codeclimate bot commented May 16, 2024

Code Climate has analyzed commit 178068d and detected 0 issues on this pull request.

View more on Code Climate.

@gabrielgiroe1 gabrielgiroe1 self-assigned this May 16, 2024
@Paul-Bob Paul-Bob changed the title Truncate message fix: truncate long action messages to avoid overflow May 16, 2024
Copy link
Contributor

@Paul-Bob Paul-Bob left a comment

Choose a reason for hiding this comment

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

I'm approving the PR since it's respecting the request, let's just directly truncate and avoid unnecessary body re-attribution as a performance tweak.

More complex review

This solution may work sometimes but do not fix the CookieOverflow problem. We're storing the messages on flash hash and the default cookie_store has a limit of 4kb. When that limit is exceeded CookieOverflow is raised.

  def handle(**args)
    succeed "🥑"*1600
    warn "🥑"*1600
    inform "🥑"*1600
    error "🥑"*1600
    return
  end

With this truncate solution the above code snippet still breaking because the sum of the 4 truncated messages exceed the 4kb limit.

Sources:

lib/avo/base_action.rb Outdated Show resolved Hide resolved
gabrielgiroe1 and others added 2 commits May 16, 2024 17:08
Co-authored-by: Paul Bob <69730720+Paul-Bob@users.noreply.github.com>
@gabrielgiroe1 gabrielgiroe1 merged commit 9db6761 into main May 17, 2024
19 of 20 checks passed
@gabrielgiroe1 gabrielgiroe1 deleted the feature/truncate-action-status-message branch May 17, 2024 09:40
Copy link
Contributor

This PR has been merged into main. The functionality will be available in the next release.

Please check the release guide for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unfriendly behavior when Action status message is very long.
3 participants