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

Unresolved directive when generating city names #1477

Closed
norbo03 opened this issue Jan 3, 2025 · 3 comments
Closed

Unresolved directive when generating city names #1477

norbo03 opened this issue Jan 3, 2025 · 3 comments
Labels
waiting for response Waiting for response from the reporter

Comments

@norbo03
Copy link

norbo03 commented Jan 3, 2025

Describe the bug
We are using the datafaker library to generate sample data for testing in a Scala-based project. A singleton instance of the faker is implemented centrally to generate various data points, including city names in addresses.

Occasionally, a runtime exception occurs during the data generation process, indicating that datafaker is unable to resolve a directive. The issue is intermittent: sometimes the error is triggered, while other times the application completes the process successfully. This inconsistency might be due to the application's background recovery mechanism, which retries certain steps as needed.

Since the application is complex, the stack trace for this issue has been truncated to exclude internal application calls and focuses only on potentially relevant information:

01-03 08:18:24.636 ERROR         main    App: Failed with error [java.lang.RuntimeException] with message [Failed to call method net.datafaker.providers.base.Address.city() on net.datafaker.providers.base.Address@65af0c1a (args: [])]! |  
  |   | 2025-01-03 09:18:24.649 | Exception in thread "main" java.lang.RuntimeException: Failed to call method net.datafaker.providers.base.Address.city() on net.datafaker.providers.base.Address@65af0c1a (args: []) |  
  |   | 2025-01-03 09:18:24.649 | at net.datafaker.service.FakeValuesService.lambda$resolveExpression$14(FakeValuesService.java:817) |  
  |   | 2025-01-03 09:18:24.649 | at net.datafaker.service.FakeValuesService.resExp(FakeValuesService.java:757) |  
  |   | 2025-01-03 09:18:24.649 | at net.datafaker.service.FakeValuesService.resolveExpression(FakeValuesService.java:659) |  
  |   | 2025-01-03 09:18:24.649 | at net.datafaker.service.FakeValuesService.resolve(FakeValuesService.java:527) |  
  |   | 2025-01-03 09:18:24.649 | at net.datafaker.service.FakeValuesService.resolve(FakeValuesService.java:503) |  
  |   | 2025-01-03 09:18:24.649 | at net.datafaker.providers.base.AbstractProvider.resolve(AbstractProvider.java:20) |  
  |   | 2025-01-03 09:18:24.649 | at net.datafaker.providers.base.Address.cityName(Address.java:90) | 
  |   | 2025-01-03 09:18:24.649 | more ... | # Internal application calls
  |   | 2025-01-03 09:18:24.649 | at scala.Option.getOrElse(Option.scala:201) |  
  |   | 2025-01-03 09:18:24.649 | more ... | # Internal application calls
  |   | 2025-01-03 09:18:24.649 | at scala.collection.parallel.AugmentedIterableIterator.map2combiner(RemainsIterator.scala:107) |  
  |   | 2025-01-03 09:18:24.649 | at scala.collection.parallel.AugmentedIterableIterator.map2combiner$(RemainsIterator.scala:104) |  
  |   | 2025-01-03 09:18:24.649 | at scala.collection.parallel.immutable.ParVector$ParVectorIterator.map2combiner(ParVector.scala:70) |  
  |   | 2025-01-03 09:18:24.649 | at scala.collection.parallel.ParIterableLike$Map.leaf(ParIterableLike.scala:1020) |  
  |   | 2025-01-03 09:18:24.649 | at scala.collection.parallel.Task.$anonfun$tryLeaf$1(Tasks.scala:52) |  
  |   | 2025-01-03 09:18:24.649 | at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18) |  
  |   | 2025-01-03 09:18:24.649 | at scala.util.control.Breaks$$anon$1.catchBreak(Breaks.scala:97) |  
  |   | 2025-01-03 09:18:24.649 | at scala.collection.parallel.Task.tryLeaf(Tasks.scala:55) |  
  |   | 2025-01-03 09:18:24.649 | at scala.collection.parallel.Task.tryLeaf$(Tasks.scala:49) |  
  |   | 2025-01-03 09:18:24.649 | at scala.collection.parallel.ParIterableLike$Map.tryLeaf(ParIterableLike.scala:1017) |  
  |   | 2025-01-03 09:18:24.649 | at scala.collection.parallel.AdaptiveWorkStealingTasks$AWSTWrappedTask.compute(Tasks.scala:152) |  
  |   | 2025-01-03 09:18:24.649 | at scala.collection.parallel.AdaptiveWorkStealingTasks$AWSTWrappedTask.compute$(Tasks.scala:148) |  
  |   | 2025-01-03 09:18:24.649 | at scala.collection.parallel.AdaptiveWorkStealingForkJoinTasks$AWSFJTWrappedTask.compute(Tasks.scala:304) |  
  |   | 2025-01-03 09:18:24.649 | at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:194) |  
  |   | 2025-01-03 09:18:24.649 | at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) |  
  |   | 2025-01-03 09:18:24.649 | at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) |  
  |   | 2025-01-03 09:18:24.649 | at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) |  
  |   | 2025-01-03 09:18:24.649 | at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) |  
  |   | 2025-01-03 09:18:24.649 | at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) |  
  |   | 2025-01-03 09:18:24.649 | Caused by: java.lang.reflect.InvocationTargetException |  
  |   | 2025-01-03 09:18:24.649 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) |  
  |   | 2025-01-03 09:18:24.649 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) |  
  |   | 2025-01-03 09:18:24.649 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) |  
  |   | 2025-01-03 09:18:24.649 | at java.base/java.lang.reflect.Method.invoke(Method.java:569) |  
  |   | 2025-01-03 09:18:24.649 | at net.datafaker.service.FakeValuesService.lambda$resolveExpression$14(FakeValuesService.java:815) |  
  |   | 2025-01-03 09:18:24.650 | ... 30 more |  
  |   | 2025-01-03 09:18:24.650 | Caused by: java.lang.RuntimeException: Unable to resolve #{female_first_name} directive for FakerContext FakerContext{SingletonLocale{en}, net.datafaker.service.RandomService@1}. |  
  |   | 2025-01-03 09:18:24.650 | at net.datafaker.service.FakeValuesService.resolveExpression(FakeValuesService.java:662) |  
  |   | 2025-01-03 09:18:24.650 | at net.datafaker.service.FakeValuesService.resolveExpression(FakeValuesService.java:664) |  
  |   | 2025-01-03 09:18:24.650 | at net.datafaker.service.FakeValuesService.resolve(FakeValuesService.java:527) |  
  |   | 2025-01-03 09:18:24.650 | at net.datafaker.service.FakeValuesService.resolve(FakeValuesService.java:503) |  
  |   | 2025-01-03 09:18:24.650 | at net.datafaker.providers.base.AbstractProvider.resolve(AbstractProvider.java:20) |  
  |   | 2025-01-03 09:18:24.650 | at net.datafaker.providers.base.Address.city(Address.java:86) |  
  |   | 2025-01-03 09:18:24.650 | ... 35 more

To Reproduce
We are using a simple call to generate the city names using the global singleton faker. This is ofc a simplified version of the code we use, but the structure is the same in our codebase.

object GlobalHelper {
  lazy val faker = new Faker()
}

class App {
  val cityName = GlobalHelper.faker.address().cityName()
}

Expected behavior
We expect datafaker to reliably generate fake city names without any exceptions during the process.

Versions:

  • OS: Windows 11 Pro 24H2
  • JDK: OpenJDK 21.0.1
  • Scala: 2.13
  • Faker Version: 2.3.1 - 2.4.0 - 2.4.2

Additional context
We upgraded the datafaker dependency to the latest version (2.4.2) and noticed this issue. Attempting to downgrade to an older version (2.40) did not resolve the problem. We also tried rolling back by one minor version (specifically 2.3.1), but the issue persisted.

We suspect that this is not a new issue but rather one we encountered infrequently in the past. Unfortunately, it has now become a significant blocker for our testing phase. This is why we are seeking a resolution for this bug.

PS: If additional information would help identify the root cause, please let us know, and we will gladly provide any necessary details to assist in resolving this issue.

@kingthorin
Copy link
Collaborator

| | 2025-01-03 09:18:24.650 | Caused by: java.lang.RuntimeException: Unable to resolve #{female_first_name} directive for FakerContext FakerContext{SingletonLocale{en}, net.datafaker.service.RandomService@1}. |

Does not seem to match your code snippet.

@asolntsev asolntsev added the waiting for response Waiting for response from the reporter label Jan 3, 2025
@asolntsev
Copy link
Collaborator

@norbo03 Sorry, I cannot reproduce the problem. I added line faker.address().cityName() to my Scala2 project, and it works well.

Please share some reproducible example - a minimal project on Github (or maybe a zip archive etc.)

@asolntsev
Copy link
Collaborator

Closing the issue.
Feel free to reopen if we get a reproducible example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for response Waiting for response from the reporter
Projects
None yet
Development

No branches or pull requests

3 participants