zui icon indicating copy to clipboard operation
zui copied to clipboard

Dragging a bad file into queries section

Open mattnibs opened this issue 4 years ago • 1 comments

On v0.28.0, if I drop a bad file (e.g., {x:1}) into the queries section, the drag to import animation does not disappear and I get no error.

image

mattnibs avatar Nov 19 '21 19:11 mattnibs

FYI, I bumped into this too. The "animation does not disappear" seems like a pretty significant effect: The only way I could see to make my Query Library usable again was to completely close and reopen the app.

philrz avatar Nov 30 '21 21:11 philrz

I've confirmed this issue is still with us as of current Brim commit 290f138. As shown in the attached video, the following stack dump appears in DevTools:

Uncaught SyntaxError: Unexpected token x in JSON at position 1
    at JSON.parse (<anonymous>)
    at Object.parseJSONLib (/Users/phil/work/brim/dist/js/state/Queries/parsers.js:16)
    at /Users/phil/work/brim/dist/js/api/queries/import.js:16
    at Object.dispatch (/Users/phil/work/brim/node_modules/redux-thunk/lib/index.js:11)
    at QueriesApi.dispatch (<anonymous>:3665:80)
    at QueriesApi.import (/Users/phil/work/brim/dist/js/api/queries/queries-api.js:24)
    at Object.drop (/Users/phil/work/brim/dist/app/features/sidebar/hooks/index.js:46)
    at DropTargetImpl.drop (/Users/phil/work/brim/node_modules/react-dnd/dist/cjs/hooks/useDrop/DropTargetImpl.js:52)
    at determineDropResult (/Users/phil/work/brim/node_modules/dnd-core/dist/cjs/actions/dragDrop/drop.js:48)
    at /Users/phil/work/brim/node_modules/dnd-core/dist/cjs/actions/dragDrop/drop.js:29

https://user-images.githubusercontent.com/5934157/185436523-15e41567-349a-45f7-a629-64329adb9268.mp4

philrz avatar Aug 18 '22 15:08 philrz

Yup, I've seen this one too.

jameskerr avatar Aug 22 '22 17:08 jameskerr

Verified in Brim commit 8ac2379.

As shown in the attached video, attempts to drag bad files into the queries area now result in a helpful error message depending on whether it's wholly unusable (e.g., a pcap in this case) or valid JSON data that's not of the expected format for the query library ({"x": 1}). For correctly formatted JSON such as the Brimcap queries that successfully import in the video, the success message reports how many queries were imported.

https://user-images.githubusercontent.com/5934157/189197352-1ec88e9a-0f99-44ca-b51b-ab6fa2512616.mp4

Thanks @jameskerr!

philrz avatar Sep 08 '22 18:09 philrz