{"record":{"id":"e3cb5a245d8b19a2","repo":"apache/beam","slug":"unknown-delay-type-s","errorCode":null,"errorMessage":"Unknown delay type %s","messagePattern":"Unknown delay type (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/synthetic/src/main/java/org/apache/beam/sdk/io/synthetic/delay/SyntheticDelay.java","lineNumber":72,"sourceCode":"      case SLEEP:\n        Uninterruptibles.sleepUninterruptibly(\n            Math.max(0L, delay.getMillis()), TimeUnit.MILLISECONDS);\n        return delay.getMillis();\n      case MIXED:\n        // Mixed mode: for each millisecond of delay randomly choose to spin or sleep.\n        // This is enforced at millisecond granularity since that is the minimum duration that\n        // Thread.sleep() can sleep. Millisecond is also the unit of processing delay.\n        long sleepMillis = 0;\n        for (long i = 0; i < delay.getMillis(); i++) {\n          if (rnd.nextDouble() < cpuUtilizationInMixedDelay) {\n            delay(Duration.millis(1), 0.0, SyntheticOptions.DelayType.CPU, rnd);\n          } else {\n            sleepMillis += delay(Duration.millis(1), 0.0, SyntheticOptions.DelayType.SLEEP, rnd);\n          }\n        }\n        return sleepMillis;\n      default:\n        throw new IllegalArgumentException(\"Unknown delay type \" + delayType);\n    }\n  }\n\n  /** Keep cpu busy for {@code delayMillis} by calculating lots of hashes. */\n  private static void cpuDelay(long delayMillis) {\n    // Note that the delay is enforced in terms of walltime. That implies this thread may not\n    // keep CPU busy if it gets preempted by other threads. There is more of chance of this\n    // occurring in a streaming pipeline as there could be lots of threads running this. The loop\n    // measures cpu time spent for each iteration, so that these effects are some what minimized.\n\n    long cpuMicros = delayMillis * 1000;\n    Stopwatch timer = Stopwatch.createUnstarted();\n\n    while (timer.elapsed(TimeUnit.MICROSECONDS) < cpuMicros) {\n      // Find a long which hashes to HASH in lowest MASK bits.\n      // Values chosen to roughly take 1ms on typical workstation.\n      timer.start();\n      long p = INIT_PLAINTEXT;","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/synthetic/src/main/java/org/apache/beam/sdk/io/synthetic/delay/SyntheticDelay.java#L54-L90","documentation":"SyntheticDelay.delay applies a per-record or batch delay of a configured type (SLEEP to idle the thread, or CPU-busy work) for Beam's synthetic sources used in load testing. If the configured delay type doesn't match any supported enum case, the default branch throws IllegalArgumentException naming the type.","triggerScenarios":"Configuring synthetic source options with an unknown 'delayType' (e.g., in the load-test pipeline's --runnerOptions/synthetic JSON) and processing a record; the static delay(...) is also recursively called for average/sigma delays, so any nested call with an invalid type triggers it.","commonSituations":"Typos in load-test pipeline options ('slep' vs 'sleep'), options copied from different Beam versions with different enum sets, or programmatic construction of SyntheticOptions.DelayType with a stale value.","solutions":["Correct the delay type in your options to a supported value (e.g., SLEEP) as defined by SyntheticOptions.DelayType in your Beam version.","Check for case-sensitivity/typo issues in the JSON options file driving the synthetic source.","If constructing options programmatically, use the DelayType enum constants instead of raw strings."],"exampleFix":"// before (options JSON)\n{\"delayType\": \"THREAD_WAIT\", \"avgDelayMillis\": 10}\n// after\n{\"delayType\": \"SLEEP\", \"avgDelayMillis\": 10}","handlingStrategy":"validation","validationCode":"// Java — verify delay type before building options\nString t = opts.get(\"delayType\").asText();\nif (!t.equals(\"SLEEP\") && !t.equals(\"NONE\")) { // check against your Beam version's DelayType values\n  throw new IllegalArgumentException(\"Unsupported delayType: \" + t);\n}","typeGuard":null,"tryCatchPattern":"try {\n  long ms = SyntheticDelay.delay(base, sigma, delayType, rnd);\n} catch (IllegalArgumentException e) {\n  // unknown delay type: correct the DelayType in synthetic options\n}","preventionTips":["Use the DelayType enum constants, never free-form strings.","Check your Beam version's SyntheticOptions.DelayType for supported values.","Avoid typos in load-test pipeline option JSON; lint option files in CI."],"tags":["apache-beam","java","synthetic-source","delay","options-parsing"],"backgroundTag":"invalid-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}