graylog2-server icon indicating copy to clipboard operation
graylog2-server copied to clipboard

User can't upload content pack due to json format error

Open maxiadlovskii opened this issue 3 years ago • 1 comments

Expected Behavior

JSON format of the downloaded content pack is correct and the user able to upload it

Current Behavior

When the user downloads the content pack from the list then it's impossible to upload it

https://user-images.githubusercontent.com/10741557/159505966-b61692ce-8027-4d75-9889-6c7bd8e3596f.mp4

Possible Solution

Looks like there is a problem with JSON format when the user downloads the content pack from the list of packs. This problem does not exist when a user downloads a content pack while creating.

Steps to Reproduce (for bugs)

  1. go to system/contentpacks
  2. choose any of the existing content pack
  3. click More Action and then download the pack
  4. Click Upload button and choose the downloaded content pack
  5. You will see an error that there is a problem with JSON format and it's impossible to upload pack

Your Environment

  • Graylog Version: Graylog 4.3.0-beta.2+a61a34c
  • Operating System: Mac OS Monterey 12.2.1 (21D62)
  • Browser version: Chrome Version 99.0.4844.74 (Official Build) (arm64)

maxiadlovskii avatar Mar 22 '22 14:03 maxiadlovskii

I believe I have encountered the same error today too. I looked into it too, and the root cause appears the be that the content pack revision is already uploaded. The backend server is returning the correct error detail, but the formatting/wording of the error message in the frontend is a bit hard to read, but looking towards the end, the following text:

Error importing content pack, please ensure it is a valid JSON file. Check your Graylog logs for more information.
Content pack e8cf0d74-f644-48f7-bd40-d54a20f350e3 with this revision 3 already found!

image

The last part of the error message indicates that the content pack revision is already uploaded.

To fix this, I think we should improve the format/wording of the error message. As coded now, it indicates the JSON file might be invalid apparently globally for all errors. That is misleading. Perhaps that can just be changed to:

An error occurred uploading the content pack: [specific error here].

The raw HTML (<br /><small>) displayed in the error should also be cleaned up.

For reference in the backend, the error condition for the content pack already existing is returned here: https://github.com/Graylog2/graylog2-server/blob/b1e4d0c240026bd648219370d8b8625199f7da53/graylog2-server/src/main/java/org/graylog2/rest/resources/system/contentpacks/ContentPackResource.java#L211

danotorrey avatar Jul 01 '22 19:07 danotorrey