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

Truncate InvalidCallbackReturnValue size? #2658

Open
stdedos opened this issue Oct 10, 2023 · 4 comments · May be fixed by #2663
Open

Truncate InvalidCallbackReturnValue size? #2658

stdedos opened this issue Oct 10, 2023 · 4 comments · May be fixed by #2663

Comments

@stdedos
Copy link

stdedos commented Oct 10, 2023

Would you consider truncating/ellipsisizing the {bad_val} output of

https://github.com/plotly/dash/blob/c729ef82e179623592d033929126f284837fd178/dash/_validate.py#L238C26-L253

?

Sometimes the output can be humongous, which affects browser rendering 😕

@alexcjohnson
Copy link
Collaborator

Great point! Feel like creating a PR? we should probably keep the existing behavior for reasonably-sized objects, but then past some size (1000 chars?) truncate and say something like ... (truncated - 1543464 characters total)

@stdedos
Copy link
Author

stdedos commented Oct 10, 2023

Sure, why not? Anything can be done; but please give me your (repo's) requirements:

  • How easy / complex you'd like the solution?
  • Ellipsize / Truncate (with or without ...s?)
  • ... at how many characters?
  • ... with the text-prompt you included?

Maybe I can donate that even tomorrow.

@alexcjohnson
Copy link
Collaborator

Excellent, thank you in advance 😎

How easy / complex you'd like the solution?

As simple as possible while getting the job done. Particularly in error handling, short & readable code is more important to us than performance.

Ellipsize / Truncate (with or without ...s?)
... at how many characters?
... with the text-prompt you included?

Thinking about this more, since this error is always about a bad type we don't need that many characters, just enough to help you find the object in your code. So maybe 100 characters, then yes, ... plus a description like in my comment so it's clear to the reader what we did.

stdedos added a commit to stdedos/dash that referenced this issue Oct 12, 2023
Truncate the stringified value of `bad_val`,
in order to avoid excessive output on the debug pop-up.

Fixes plotly#2658

Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>
@stdedos stdedos linked a pull request Oct 12, 2023 that will close this issue
@stdedos
Copy link
Author

stdedos commented Oct 12, 2023

The simplest one would've been {bad_val:.100s}, but not all classes implement __format__ 😅 (in my case, a @dataclass)
... neither would it have had the requested bells and whistles.

and {bad_val!s} does not support the format-language (so !.100s is invalid)

🙃

I have sent my review - I hope it is straightforward.

stdedos added a commit to stdedos/dash that referenced this issue Oct 12, 2023
Truncate the stringified value of `bad_val`,
in order to avoid excessive output on the debug pop-up.

Fixes plotly#2658

Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>
stdedos added a commit to stdedos/dash that referenced this issue Nov 13, 2023
Truncate the stringified value of `bad_val`,
in order to avoid excessive output on the debug pop-up.

Fixes plotly#2658

Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants