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

Unfriendly behavior when Action status message is very long. #2707

Closed
4 of 11 tasks
MrJoy opened this issue Apr 18, 2024 · 4 comments · Fixed by #2773
Closed
4 of 11 tasks

Unfriendly behavior when Action status message is very long. #2707

MrJoy opened this issue Apr 18, 2024 · 4 comments · Fixed by #2773
Assignees
Labels
Bug Something isn't working Task Something to get done

Comments

@MrJoy
Copy link
Contributor

MrJoy commented Apr 18, 2024

Describe the bug

I just spent about 20 minutes trying to figure out why I couldn't get a toast with the result of an Action. It turns out the action was doing this:

error("Unknown error: #{e.message}")

And the resulting error message length was causing the session cookie to exceed 4KB. I noticed that via a warning in the browser console.

I assume this is due to how Rails handles flash messages.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create an action, and expose it on the resource. The action should produce a response that is very long. (In my case, e.message.length was 1,644.)
  2. Run the action.

Expected behavior & Actual behavior

It would be nice if Avo would report that something went wrong and the result couldn't be presented. Or, perhaps, if it truncated the message before tossing it in the session hash (although finding an acceptable limit for that could be challenging).

It would be even nicer if the response to the action wasn't conveyed via the session object. At least, not when the response is a normal Turbo response and not a redirect or download.

Models and resource files

System configuration

Avo version: 3.6.1

Rails version: 7.1.3.2

Ruby version: 3.2.2

License type:

  • Community
  • Pro
  • Advanced

Are you using Avo monkey patches, overriding views or view components?

  • Yes. If so, please post code samples.
  • No

Screenshots or screen recordings

Additional context

Impact

  • High impact (It makes my app un-usable.)
  • Medium impact (I'm annoyed, but I'll live.)
  • Low impact (It's really a tiny thing that I could live with.)

Urgency

  • High urgency (I can't continue development without it.)
  • Medium urgency (I found a workaround, but I'd love to have it fixed.)
  • Low urgency (It can wait. I just wanted you to know about it.)
@adrianthedev
Copy link
Collaborator

Hey @MrJoy.
I know it's frustrating when things fail silently, but it's incredibly hard for us to detect these kinds of issues in advance.
I mean... I didn't really know about that limit, and nowhere in the Rails docs is that mentioned as an issue that we should take into account.

It would be even nicer if the response to the action wasn't conveyed via the session object. At least, not when the response is a normal Turbo response and not a redirect or download.

The response here is pretty much "default", wouldn't you say?

def update_fail_action
  respond_to do |format|
    flash.now[:error] = update_fail_message
    format.html { render :edit, status: :unprocessable_entity }
  end
end

This is pretty much what we do.

My question is, does a 1.6K character message really makes sense to display to the user?

My proposal is to truncate that message to x amount of characters.
How much should that x be? Would 500 be enough?

@MrJoy
Copy link
Contributor Author

MrJoy commented Apr 24, 2024

Truncation would be totally fine. I'd say -- for the same reason you imply -- that even shorter would be acceptable. I'm currently truncating any variable-length message to 100 characters.

Copy link
Contributor

github-actions bot commented May 9, 2024

This issue has been marked as stale because there was no activity for the past 15 days.

@github-actions github-actions bot added the Stale label May 9, 2024
@adrianthedev adrianthedev added Bug Something isn't working Task Something to get done and removed Stale labels May 9, 2024
@adrianthedev
Copy link
Collaborator

Let's truncate to 320 characters @gabrielgiroe1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Task Something to get done
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants