Closed ganeshnikam18 closed 5 months ago
Hi @ganeshnikam18. Thank you for reporting this issue. Let me check what's happening.
@ganeshnikam18 Thank you for the detailed report, very well written. And also for the fix. It will be available in the next release.
This should be fix in latest release: https://github.com/Endava/cats/releases/tag/cats-10.4.0
I'll close this as fixed.
Describe the bug I have locally built the cats-runner.jar using the mvwn command. Trying to run the tool on one of the custom perstore.json file. In this run cats-runner.jar is crashing with " java.lang.NullPointerException". Here are the complete details:
CATS version: 10.3.0 Petstore Speci File: petstore.json
For the server side, I am running Spotlight Prism Mock Server:
The stacktrace of the crash:
[******][*******] ◯ key application/json contentType application\/.*\+?json;?.* java.lang.NullPointerException: Cannot invoke "io.swagger.v3.oas.models.media.Schema.get$ref()" because the return value of "io.swagger.v3.oas.models.media.MediaType.getSchema()" is null at com.endava.cats.factory.FuzzingDataFactory.getCurrentRequestSchemaName(FuzzingDataFactory.java:356) at com.endava.cats.factory.FuzzingDataFactory.getFuzzDataForHttpMethod(FuzzingDataFactory.java:204) at com.endava.cats.factory.FuzzingDataFactory.getFuzzDataForPost(FuzzingDataFactory.java:157) at com.endava.cats.factory.FuzzingDataFactory.fromPathItem(FuzzingDataFactory.java:88) at com.endava.cats.factory.FuzzingDataFactory_ClientProxy.fromPathItem(Unknown Source) at com.endava.cats.command.CatsCommand.fuzzPath(CatsCommand.java:321) at com.endava.cats.command.CatsCommand.startFuzzing(CatsCommand.java:261) at com.endava.cats.command.CatsCommand.doLogic(CatsCommand.java:204) at com.endava.cats.command.CatsCommand.run(CatsCommand.java:156) at picocli.CommandLine.executeUserObject(CommandLine.java:2026) at picocli.CommandLine.access$1500(CommandLine.java:148) at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461) at picocli.CommandLine$RunLast.handle(CommandLine.java:2453) at picocli.CommandLine$RunLast.handle(CommandLine.java:2415) at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273) at picocli.CommandLine$RunLast.execute(CommandLine.java:2417) at picocli.CommandLine.execute(CommandLine.java:2170) at com.endava.cats.CatsMain.run(CatsMain.java:39) at com.endava.cats.CatsMain_ClientProxy.run(Unknown Source) at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:132) at io.quarkus.runtime.Quarkus.run(Quarkus.java:71) at io.quarkus.runtime.Quarkus.run(Quarkus.java:44) at io.quarkus.runner.GeneratedMain.main(Unknown Source) ganesh@ganesh-vm:~/cats-original/cats-cats-10.3.0$
To Reproduce Steps to reproduce the behaviour:
docker run --init --rm -v $(pwd):/tmp -p 4010:4010 stoplight/prism:4 mock -h 0.0.0.0 "/tmp/petstore.json
java -jar target/cats-runner.jar --server=http://<mock-server-ip>:4010 --contract=petstore.json --fuzzers=HappyPathFuzzer --log=com.endava.cats:debug --verbosity=DETAILED
Expected behaviour The cats tool should not crash
Below mentioned request body in the contract causing this crash
"post": { "summary": "Create a pet", "operationId": "createPets", "tags": [ "pets" ], "requestBody": { "content": { "application/json": {} }, "required": true },
Ideally requestBody should not be empty (without specifying schema). But some spec file do get published like this. What is the fix ? We have to add the NULL check for schema presence. Check below image for patch.![Screenshot 2024-01-09 153154-11](https://github.com/Endava/cats/assets/11749677/b3239c83-306a-4287-8bb0-8d23ed2e6f23)