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

Out of bounds for length 0 #125

Closed
ctwinovalon opened this issue May 24, 2024 · 5 comments
Closed

Out of bounds for length 0 #125

ctwinovalon opened this issue May 24, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@ctwinovalon
Copy link

Ran --server xyz --contract file.json

Ran for a while on various endpoints and died on one of them with:

java.lang.StringIndexOutOfBoundsException: Range [-1, 0) out of bounds for length 0
...
com.endava.cats.generator.simple.StringGenerator.generateExactLength(StringGenerator.java:127)
@ctwinovalon ctwinovalon added the bug Something isn't working label May 24, 2024
@ctwinovalon
Copy link
Author

ctwinovalon commented May 24, 2024

Looks like this section:

if (initialValue.length() != length) {
int startingAt = initialValue.length() - 1;
String toRepeat = initialValue.substring(startingAt);
initialValue.append(toRepeat);
while (initialValue.length() < length) {
initialValue.append(toRepeat);
}
}

The test if (initialValue.length() != length) { should be if (initialValue.length() > 0 && initialValue.length() != length) {

@en-milie
Copy link
Contributor

Hi @ctwinovalon. Can you please attach an OpenApi spec i can use to reproduce the issue?

@ctwinovalon
Copy link
Author

api-docs3.json

@en-milie
Copy link
Contributor

Thank you for providing the specs. This is now fixed in: 1f936a9

@en-milie
Copy link
Contributor

en-milie commented Jun 7, 2024

It should be fixed in: https://github.com/Endava/cats/releases/tag/cats-11.7.0

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