Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cmd-api-server): no CLI args causes crash #794

Closed
petermetz opened this issue Apr 14, 2021 · 0 comments · Fixed by #795
Closed

fix(cmd-api-server): no CLI args causes crash #794

petermetz opened this issue Apr 14, 2021 · 0 comments · Fixed by #795
Assignees
Labels
API_Server bug Something isn't working

Comments

@petermetz
Copy link
Member

Describe the bug

When the presence of the help command gets examined it is assumed that there's at least one CLI arg provided. When this is not the case, a crash occurs.

To Reproduce

RUN npm i @hyperledger/cactus-cmd-api-server@${NPM_PKG_VERSION} --production

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "node_modules/@hyperledger/cactus-cmd-api-server/dist/lib/main/typescript/cmd/cactus-api.js"]

Expected behavior

No crash when there are no CLI args for the API server (since we can fully configure it through ENV or config file as well.

Logs/Stack traces

$ docker run --rm --publish 3000:3000 --publish 4000:4000 cas                                                                    
[2021-04-14T05:07:15.560Z] INFO (config-service): Configuration validation OK.                                                                                                                                                      
[2021-04-14T05:07:15.561Z] ERROR (cactus-api): Cactus API server crashed:  TypeError: Cannot read property 'includes' of undefined
    at main (/usr/src/app/node_modules/@hyperledger/cactus-cmd-api-server/dist/lib/main/typescript/cmd/cactus-api.js:17:25)
    at launchApp (/usr/src/app/node_modules/@hyperledger/cactus-cmd-api-server/dist/lib/main/typescript/cmd/cactus-api.js:30:15)
    at Object.<anonymous> (/usr/src/app/node_modules/@hyperledger/cactus-cmd-api-server/dist/lib/main/typescript/cmd/cactus-api.js:40:5)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)

Screenshots

N/A

Cloud provider or hardware configuration:

Dev machine

Operating system name, version, build:

Alpine Linux (container)

Hyperledger Cactus release version or commit (git rev-parse --short HEAD):

0.4.1

Hyperledger Cactus Plugins/Connectors Used

N/A

Additional context

N/A

cc: @takeutak @sfuji822 @hartm @jonathan-m-hamilton @AzaharaC @jordigiam @kikoncuo @jagpreetsinghsasan

@petermetz petermetz added API_Server bug Something isn't working labels Apr 14, 2021
@petermetz petermetz self-assigned this Apr 14, 2021
petermetz added a commit to petermetz/cacti that referenced this issue Apr 14, 2021
Guard against examinig the help command's presence if there's no
CLI arguments specified at all.

Fixes hyperledger#794

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz added a commit that referenced this issue Apr 16, 2021
Guard against examinig the help command's presence if there's no
CLI arguments specified at all.

Fixes #794

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API_Server bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant