{"record":{"id":"8546b7b858fa2d85","repo":"apache/beam","slug":"failed-to-determine-if-the-source-is-splittable","errorCode":null,"errorMessage":"Failed to determine if the source is splittable","messagePattern":"Failed to determine if the source is splittable","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/io/CompressedSource.java","lineNumber":232,"sourceCode":"  /**\n   * Creates a {@code CompressedSource} for an individual file. Used by {@link\n   * CompressedSource#createForSubrangeOfFile}.\n   */\n  private CompressedSource(\n      FileBasedSource<T> sourceDelegate,\n      DecompressingChannelFactory channelFactory,\n      Metadata metadata,\n      long minBundleSize,\n      long startOffset,\n      long endOffset) {\n    super(metadata, minBundleSize, startOffset, endOffset);\n    this.sourceDelegate = sourceDelegate;\n    this.channelFactory = channelFactory;\n    boolean splittable;\n    try {\n      splittable = isSplittable();\n    } catch (Exception e) {\n      throw new RuntimeException(\"Failed to determine if the source is splittable\", e);\n    }\n    checkArgument(\n        splittable || startOffset == 0,\n        \"CompressedSources must start reading at offset 0. Requested offset: %s\",\n        startOffset);\n  }\n\n  /**\n   * Validates that the delegate source is a valid source and that the channel factory is not null.\n   */\n  @Override\n  public void validate() {\n    super.validate();\n    checkNotNull(sourceDelegate);\n    sourceDelegate.validate();\n    checkNotNull(channelFactory);\n  }\n","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/io/CompressedSource.java#L214-L250","documentation":"The CompressedSource constructor calls isSplittable() on the delegate source to decide whether offsets can be split; if that check throws for any reason, the exception is wrapped in a RuntimeException 'Failed to determine if the source is splittable'. This is an internal precondition failure, usually caused by the delegate's isSplittable() implementation throwing.","triggerScenarios":"Constructing a CompressedSource whose delegate FileBasedSource.isSplittable() throws (e.g., a custom source throwing in isSplittable, or IO errors during filename/mode checks); creating sub-sources during dynamic work rebalancing.","commonSituations":"Custom FileBasedSource implementations with buggy isSplittable(); compressed inputs over flaky filesystems where metadata checks fail; version-mismatched delegate sources.","solutions":["Fix or wrap the delegate source's isSplittable() so it does not throw; inspect the cause via getCause().","Ensure the delegate's file is accessible/readable before constructing the CompressedSource.","For custom sources, make isSplittable() return false safely for compressed/unsplittable files instead of throwing."],"exampleFix":"// before\n@Override protected boolean isSplittable() throws Exception {\n  return Files.size(path) > 0; // throws if path inaccessible\n}\n// after\n@Override protected boolean isSplittable() throws Exception {\n  try { return Files.size(path) > 0; } catch (IOException e) { return false; }\n}","handlingStrategy":"try-catch","validationCode":"// verify delegate source is readable before constructing\ntry (FileChannel ch = FileChannel.open(path)) { /* accessible */ }","typeGuard":null,"tryCatchPattern":"try {\n  CompressedSource src = new CompressedSource(delegate, offset, factory);\n} catch (RuntimeException e) {\n  logger.error(\"splittable check failed\", e.getCause()); // inspect cause\n}","preventionTips":["Implement isSplittable() defensively in custom FileBasedSource subclasses","Verify input file accessibility before source construction","Keep compressed sources at offset 0 when non-splittable"],"tags":["java","io","compression","runtime-exception"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}