f3d-app / f3d

Fast and minimalist 3D viewer.
https://f3d.app
BSD 3-Clause "New" or "Revised" License
2.91k stars 211 forks source link

F3D exits with error code 0 (success) despite an error having occurred (invalid json config file) #1103

Closed mrdeveloperdude closed 11 months ago

mrdeveloperdude commented 11 months ago

Describe the bug

When running f3d with an invalid json file as input to the --config commandline parameter, it exits with an error message output on stderr but returns exit code 0 to the shell, which signifies success.

The error message that f3d outputs looks like this:

"/tmp/myconfig.json" is not a file of a supported file format.
This is a headless build of F3D, interactive rendering is not supported

This constitutes 2 distinct problems;

  1. F3D exists with 0 when clearly there is an error preventing normal operation
  2. F3D tries to default to interactive mode upon failing to read the json and subsequently fails since we are using the headless version which has no support for interactive mode.

To Reproduce Steps to reproduce the behavior:

  1. Create an invalid json file on disk named test.json
  2. Run headless version of F3D (other versions may be affected as well) like so: f3d --config=test.json

Expected behavior I expect the program to report the error and exit with a non-zero exit code such as 1

System Information:

Meakk commented 11 months ago

Probably related to https://github.com/f3d-app/f3d/issues/310 Are you using the occt plugin?

mwestphal commented 11 months ago

Please share your "myconfig.json" file

mwestphal commented 11 months ago

here is the file that was invalid for @mrdeveloperdude , but it is working well for me.

Test_files_F3D.zip

Lets consider that for this issue, the .json is just invalid and we should improve error management in this context

snoyer commented 11 months ago

Original info from the Discord discussion:

Commandline looks like this: /usr/bin/f3d --config= /tmp/1FGYnjiFIDanGgzNtCGOBT0bCfaO1fzdu_1702839294626.json /tmp/1FGYnjiFIDanGgzNtCGOBT0bCfaO1fzdu_1702839294626.stl .stl file is present and should be valid The error output produced by f3d looks like this: "/tmp/1FGYnjiFIDanGgzNtCGOBT0bCfaO1fzdu_1702839294626.json" is not a file of a supported file format This is a headless build of F3D, interactive rendering is not supported (produced on stderr)

"foo.bar" is not a file of a supported file format is the message you get when opening an invalid scene/model/3d file.

The command /usr/bin/f3d --config= foo.json bar.stl has a space after --config= so config is actually "" and foo.json is part of the inputs. --config=foo.json (equal and no space) or --config foo.json (no equal) should work, assuming the json file is valid

Even though this is not a bug, possible improvements on F3D's side include:

mwestphal commented 11 months ago

Ask and you shall receive, @snoyer :)

mwestphal commented 11 months ago

So I did not adress the incorrect syntax --config= path/to/conf.json. cxxops is unhelpfull so this will wait for #434

mwestphal commented 11 months ago

All other point raised by @snoyer have been adressed.