{"record":{"id":"057888bdad5bdb99","repo":"apache/beam","slug":"un-globbable-filesystem","errorCode":null,"errorMessage":"Un-globbable filesystem.","messagePattern":"Un-globbable filesystem\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/io/ClassLoaderFileSystem.java","lineNumber":52,"sourceCode":"import org.apache.beam.sdk.io.fs.ResourceId;\nimport org.apache.beam.sdk.options.PipelineOptions;\nimport org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableList;\nimport org.checkerframework.checker.nullness.qual.Nullable;\n\n/** A read-only {@link FileSystem} implementation looking up resources using a ClassLoader. */\n@SuppressWarnings({\n  \"nullness\" // TODO(https://github.com/apache/beam/issues/20497)\n})\npublic class ClassLoaderFileSystem extends FileSystem<ClassLoaderFileSystem.ClassLoaderResourceId> {\n\n  public static final String SCHEMA = \"classpath\";\n  private static final String PREFIX = SCHEMA + \"://\";\n\n  ClassLoaderFileSystem() {}\n\n  @Override\n  protected List<MatchResult> match(List<String> specs) throws IOException {\n    throw new UnsupportedOperationException(\"Un-globbable filesystem.\");\n  }\n\n  @Override\n  protected WritableByteChannel create(\n      ClassLoaderResourceId resourceId, CreateOptions createOptions) throws IOException {\n    throw new UnsupportedOperationException(\"Read-only filesystem.\");\n  }\n\n  @Override\n  protected ReadableByteChannel open(ClassLoaderResourceId resourceId) throws IOException {\n    ClassLoader classLoader = getClass().getClassLoader();\n    InputStream inputStream =\n        classLoader.getResourceAsStream(resourceId.path.substring(PREFIX.length()));\n    if (inputStream == null) {\n\n      throw new IOException(\n          \"Unable to load \"\n              + resourceId.path","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/io/ClassLoaderFileSystem.java#L34-L70","documentation":"ClassLoaderFileSystem exposes classpath resources as a read-only Beam filesystem, but classpath resources are not enumerable as paths, so glob matching and listing cannot be performed. Its match implementation always throws UnsupportedOperationException('Un-globbable filesystem.').","triggerScenarios":"Calling FileSystems.match (directly or via IO expansion) on a classpath:// spec, especially with wildcards; metadata resolution against classpath URLs.","commonSituations":"Users pointing Beam IO sources at classpath:// paths expecting wildcard expansion; pipelines configured to read inputs via classpath URIs with glob patterns.","solutions":["Do not glob classpath:// paths; reference exact resource paths via open/read instead","Expand the pattern yourself against known resource names, then open each exact path","Copy resources from the classpath to a real (local/GCS) filesystem and use that schema for globbing","Use FileSystems.open with a fully specified resource id rather than match"],"exampleFix":"// before\nFileSystems.match(java.util.Collections.singletonList(\"classpath://data/*.json\")); // throws\n// after\nReadableByteChannel ch = FileSystems.open(\n    FileSystems.matchNewResource(\"classpath://data/exact-file.json\", false));","handlingStrategy":"try-catch","validationCode":"if (spec.startsWith(\"classpath://\") && spec.contains(\"*\")) {\n  throw new IllegalArgumentException(\"cannot glob classpath resources\");\n}","typeGuard":"static boolean isGlobbable(String spec) {\n  return !spec.startsWith(\"classpath://\");\n}","tryCatchPattern":"try {\n  return FileSystems.match(specs);\n} catch (UnsupportedOperationException e) {\n  // fall back to exact resource paths\n}","preventionTips":["Never use wildcards with classpath:// paths","Enumerate candidate resource names in code and open them individually","Use real filesystems for glob/list workloads"],"tags":["java","io","filesystem","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}