zowe / zss

Zowe System Services Server for enabling low-level microservices
Eclipse Public License 2.0
13 stars 45 forks source link

configmgr sometimes gives bad error code for nonexistent yaml #716

Open nosrednayduj opened 1 month ago

nosrednayduj commented 1 month ago

Describe the bug Config manager has some error checking, but it fails when a missing file is the last one in the configuration that it is manipulating.

configmgr.c overloadConfiguration function is a recursive function but it appears not to check errors in its final call (pathTail == NULL). It gives a message saying it couldn't read the file, but the return code from config manager is zero.

Putting an existing file after the nonexistent file gives a second error message and return code 7.

Steps to Reproduce

$ ./configmgr -s /some/valid/schema -p "FILE(/existing/file):FILE(/nonexistant/file)" env /output/file.env

Expected behavior Error message and nonzero return code. We get an error message, but return code is helpful for scripting.

Screenshots (if needed) Showing problem:

$ ./configmgr -s /some/valid/schema -p "FILE(/existing/file):FILE(/nonexistant/file)" env /output/file.env
ZWEL0318E - failed to read '/nonexistant/file.yaml' - EDC5129I No such file or directory.
$ echo $?
0

With existing file last, showing error code:

$ ./configmgr -s /some/valid/schema -p "FILE(/nonexistant/file):FILE(/existing/file)" env /output/file.env
ZWEL0318E - failed to read '/nonexistant/file.yaml' - EDC5129I No such file or directory.
ZWEL0319E - Failed to load configuration, element may be bad, or less likely a bad merge.
$ echo $?
7

Logs

Describe your environment

Additional context Side note: the 319 error message does not appear when you are calling it from rexx, but you do get the return code 7 if you put the existing file last. The 318 error message does appear calling from rexx in both cases; gets return code 0 if the nonexistent file is last. So I think probably fixing this will fix rexx.

JoeNemo commented 3 weeks ago

It looks like somehow the logic that generates ZWEL0318E message does not flow into a place that changes the config manager return status from:

return ZCFG_SUCCESS;

However it does change it when flowing through the code that generates the ZWEL0319E.

@Gautham-coder I hope you investigate.

Gautham-coder commented 3 weeks ago

Sure Joe, I will look into it. Thanks