java-faker icon indicating copy to clipboard operation
java-faker copied to clipboard

Company.name throws java.lang.RuntimeException: Unable to resolve #{suffix} directive

Open gurudattgd04 opened this issue 4 years ago • 3 comments

Describe the bug I pass the faker key from json file and then get value for it. Using company.name is throwing java.lang.RuntimeException: Unable to resolve #{suffix} directive error often. Sometime it works and sometime it throws the exception

To Reproduce use the company.name faker, run couple of times and you get exception

Expected behavior Should return company name

Versions:

  • OS: Windows 10
  • JDK 1.8
  • Faker Version [1.0.2]

Additional context From the debug, what i observed is, when company.name is passed, fake converts that to name.last_name and starts adding words.

First time a word is returned and during second loop, for some reasons fakervalueservice returning #{suffix} and it throws the exception

Attached the debugger screenshot for further reference FakerDebug

gurudattgd04 avatar Oct 06 '20 13:10 gurudattgd04

Our gruop have looked carefully at your issue and we're interested. We will try to solve this problem.

--SE_CHWJ

nanfang-wuyu avatar Mar 10 '21 14:03 nanfang-wuyu

Sorry that we can't reproduce your problem, could you please try it again and if it's still wrong, could you please show more screenshots and details how the error happened, by the way, the screenshot seems to be different from the class in version 1.0.2 in FakeValuesService class, hope you check and best wishes.

nanfang-wuyu avatar May 22 '21 10:05 nanfang-wuyu

I also experience the same issue with company.name The problem is that it is not reproduced all the time (~1 failure on 10 executions)

Caused by: java.lang.RuntimeException: Unable to resolve #{suffix} directive.
	at com.github.javafaker.service.FakeValuesService.resolveExpression(FakeValuesService.java:360)
	at com.github.javafaker.service.FakeValuesService.resolveExpression(FakeValuesService.java:363)
	at com.github.javafaker.service.FakeValuesService.expression(FakeValuesService.java:322)
	at com.github.javafaker.Faker.expression(Faker.java:715)

I am trying to evaluate the expression: #{company.name} image

But when it comes to resolveExpression method it fails to resolve it: image

Jazzyekim avatar Jul 28 '22 08:07 Jazzyekim