{"record":{"id":"2eff59cd2798dada","repo":"apache/hadoop","slug":"doesn-t-support-createsnapshot","errorCode":null,"errorMessage":"{} doesn't support createSnapshot","messagePattern":"(.+?) doesn't support createSnapshot","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java","lineNumber":1482,"sourceCode":"   * @throws IOException raised on errors performing I/O.\n   */\n  public void removeXAttr(Path path, String name) throws IOException {\n    throw new UnsupportedOperationException(getClass().getSimpleName()\n        + \" doesn't support removeXAttr\");\n  }\n\n  /**\n   * The specification of this method matches that of\n   * {@link FileContext#createSnapshot(Path, String)}.\n   *\n   * @param path the path.\n   * @param snapshotName snapshot name.\n   * @throws IOException raised on errors performing I/O.\n   * @return path.\n   */\n  public Path createSnapshot(final Path path, final String snapshotName)\n      throws IOException {\n    throw new UnsupportedOperationException(getClass().getSimpleName()\n        + \" doesn't support createSnapshot\");\n  }\n\n  /**\n   * The specification of this method matches that of\n   * {@link FileContext#renameSnapshot(Path, String, String)}.\n   *\n   * @param path the path.\n   * @param snapshotOldName snapshot old name.\n   * @param snapshotNewName snapshot new name.\n   * @throws IOException raised on errors performing I/O.\n   */\n  public void renameSnapshot(final Path path, final String snapshotOldName,\n      final String snapshotNewName) throws IOException {\n    throw new UnsupportedOperationException(getClass().getSimpleName()\n        + \" doesn't support renameSnapshot\");\n  }\n","sourceCodeStart":1464,"sourceCodeEnd":1500,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java#L1464-L1500","documentation":"Snapshots are an HDFS-only feature; AbstractFileSystem.createSnapshot(Path, String) is a default stub that throws UnsupportedOperationException naming the subclass. The method is only overridden by HDFS-backed implementations (Hdfs, WebHDFS, and viewfs mount entries that delegate to them). Seeing this error means you asked a non-HDFS filesystem to create a snapshot.","triggerScenarios":"FileContext.createSnapshot(path, name) on local, object-store, or ftp schemes; a viewfs (mount-table) path whose target resolves to a non-HDFS store; snapshot-based backup tooling written against FileContext run with the wrong defaultFS.","commonSituations":"Portable backup/rollback scripts assume snapshots everywhere; a job configured with fs.defaultFS=file:/// in tests or a cluster migration repoints snapshot calls at unsupported stores. Note that even on HDFS the directory must first allow snapshots (a different error - SnapshotException - if not enabled).","solutions":["Confirm the target path is hdfs:// (or webhdfs://) and that the mounted AbstractFileSystem is HDFS-backed; use that path for snapshot calls.","Prefer the HDFS-specific API surface (DistributedFileSystem.createSnapshot / HdfsAdmin) which makes the HDFS requirement explicit.","On HDFS, enable snapshots first with `hdfs dfsadmin -allowSnapshot <dir>` (that avoids the follow-on SnapshotException).","Catch UnsupportedOperationException and skip snapshotting when the filesystem does not support it."],"exampleFix":"// before\nPath snap = fc.createSnapshot(dir, \"daily-1\"); // throws on file:// or s3a://\n\n// after\nif (\"hdfs\".equals(dir.toUri().getScheme())) {\n  Path snap = fc.createSnapshot(dir, \"daily-1\");\n} else {\n  LOG.warn(\"Snapshots unsupported on {}\", dir.toUri().getScheme());\n}","handlingStrategy":"validation","validationCode":"static boolean isSnapshotCapable(Path p) {\n  String scheme = p.toUri().getScheme();\n  return \"hdfs\".equals(scheme) || \"webhdfs\".equals(scheme);\n}","typeGuard":null,"tryCatchPattern":"try {\n  fc.createSnapshot(dir, name);\n} catch (UnsupportedOperationException e) {\n  LOG.warn(\"snapshots unsupported on {}: skipping\", dir);\n}","preventionTips":["Gate snapshot APIs on an hdfs/webhdfs scheme check","Prefer HdfsAdmin/DistributedFileSystem for snapshot work so the contract is explicit","Remember snapshots must also be allowed on the directory (hdfs dfsadmin -allowSnapshot)"],"tags":["hadoop","filesystem","hdfs-snapshot","filecontext","unsupportedoperationexception"],"backgroundTag":"snapshots-unsupported","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}