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

java.lang.IllegalArgumentException When header.yaml file is given as input #110

Closed
ganeshnikam18 opened this issue Mar 4, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@ganeshnikam18
Copy link
Contributor

Describe the bug
If we give header.yaml file as a input on the cats command line then we get below exception:

vm:~/cats$ java -jar ./target/cats-runner.jar --fuzzers=StringFieldsRightBoundaryFuzzer --server=http://api-server.com --contract=./swagger.yml --headers=./header.yml

[][] ▶ Starting cats-11.0.1-SNAPSHOT, build time 2024-02-28T18:40:31Z UTC, platform Linux-6.5.0-21-generic-amd64
[
][] ⚙ Headers file: /cats/header.yml
[
][***] ‼ Something went wrong while running CATS: java.lang.IllegalArgumentException: Cannot deserialize value of type java.util.LinkedHashMap<java.lang.Object,java.lang.Object> from Array value (token JsonToken.START_ARRAY)
at [Source: UNKNOWN; byte offset: #UNKNOWN]

This exception will come for any FileArguments like: --header, --refData --urlParam

** Steps To Reproduce**
Steps to reproduce the behaviour:

  1. Run cats command for any specification with --headers <headers.yaml> file. Content of headers.yaml file could be as below:

all:
- X-API-Key:abc123

  1. The program will crash with Exception

Expected behaviour
The headers.yaml file should be read properly and those headers should be sent in the request.

@ganeshnikam18 ganeshnikam18 added the bug Something isn't working label Mar 4, 2024
@en-milie
Copy link
Contributor

en-milie commented Mar 4, 2024

Hi @ganeshnikam18. Headers file syntax implies that headers are sub-elements of paths and all, not array values like in your example. This is why it crashes. It's probably a good idea to change a bit the message to suggest that it's an issue with the syntax.

@ganeshnikam18
Copy link
Contributor Author

@en-milie Ok. Got it. The content of the header.yaml file should be as below:

all:
X-API-Key : abc123

It will then be converted to Object, Instead of ArrayList.

Sorry for the incorrect bug

@en-milie
Copy link
Contributor

en-milie commented Mar 4, 2024

It should be as follows:

all:
  X-API-Key: abc123

Notice the indentation of the X-API-Key. It needs 2 spaces in order to be a sub-element of all.

@ganeshnikam18
Copy link
Contributor Author

Yes. Thanks for the clarification

@en-milie
Copy link
Contributor

Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants