CyberChef icon indicating copy to clipboard operation
CyberChef copied to clipboard

Bug report: empty value in input shows error and output "[object Object]" in Generate Lorem Ipsum operation

Open Noam-Bahar opened this issue 1 year ago • 3 comments

Describe the bug In the Generate Lorem Ipsum operation, entering an empty value in the Length field

  1. shows a toast popup that says "[object Object]",
  2. prints an output that says "[object Object]",
  3. the operation Generate Lorem Ipsum stays green, despite being in an error state, and
  4. logs an error message and a regular message with "[object Object]" to the browser console.

To Reproduce

  1. In the Operations tab, search for "lorem".
  2. Drag the Generate Lorem Ipsum operation to the Recipe tab.
  3. In the Length field, delete the existing value of "3". The number input should be empty.
  4. The Output block should say [object Object] the Generate Lorem Ipsum operation should stay green, and a toast with the text [object Object] will appear at the bottom of the screen.

Expected behaviour

  • A human readable error message -- either in the Output block (recipe/operation wide error), or in a form-style input validation error message (input-level error).
  • The operation block being red, in order to indicate an error state, instead of green.
  • The toast either not showing up at all -- like some other error messages -- or showing a human readable error message instead of "[object Object]".

Screenshots

Bug demonstration with browser console open:

Invalid input value (empty string) with browser console open, with bug
Expected behavior for invalid input: Expected behavior for invalid input
Bug demonstration, for comparison with the expected behavior: Bug demonstration, for comparison with the expected behavior

Desktop

  • OS: Windows 11
  • Browser: 135.0.7049.84 (Official Build, ungoogled-chromium) (64-bit)
  • CyberChef version: 10.19.4
  • Compile time: 23/07/2025 10:26:40 UTC
  • User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
  • Link to reproduce

Additional context [object Object] appears when a JS object is coerced/converted into a string without using JSON.stringify, or when an object is set as the innerHTML of an HTML element

Noam-Bahar avatar Jul 31 '25 21:07 Noam-Bahar

I think 0 should be a valid state, but an empty value for the length should either autofill to 0 or be an error state.

Length=0 is not an invalid scenario, it should correctly generate "nothing." To me this looks more like a missing edge case handler.

irebased avatar Aug 01 '25 18:08 irebased

Note: this bug also appears in the number input of the ROT13 Operation's Amount field

Noam-Bahar avatar Aug 06 '25 22:08 Noam-Bahar

@irebased An autofill to default value sounds OK, but so is an error state, and both are better than a toast with "[object Object]"

By the way, there is no limit or cap to the amount of toasts popping up -- see the screenshot below; they popped up on every keystroke in the input tab, which gets annoying. This happens with other toasts. Another bug report/feature request could be opened on this.

Regarding the 0 case which wasn't really related to my issue:

In other places a value of 0 is valid (such as in ROT13). Specifically in the Generate Lorem Ipsum operation, it seems to be invalid because you pick a length in paragraphs/sentences/words/bytes, so it has to be a positive integer to generate lorem ipsum. In my opinion, an error state makes sense here, though it could just be outputting an empty string for all I care (though what happens when -1 is entered?). This could lead to a wider discussion on standardizing the Operations' form state management and error indicators.

Image

Noam-Bahar avatar Aug 06 '25 22:08 Noam-Bahar