{"record":{"id":"421f1a17bbd53e7d","repo":"apache/hadoop","slug":"doesn-t-support-deletesnapshot","errorCode":null,"errorMessage":"{} doesn't support deleteSnapshot","messagePattern":"(.+?) doesn't support deleteSnapshot","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java","lineNumber":1511,"sourceCode":"   * @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\n  /**\n   * The specification of this method matches that of\n   * {@link FileContext#deleteSnapshot(Path, String)}.\n   *\n   * @param snapshotDir snapshot dir.\n   * @param snapshotName snapshot name.\n   * @throws IOException raised on errors performing I/O.\n   */\n  public void deleteSnapshot(final Path snapshotDir, final String snapshotName)\n      throws IOException {\n    throw new UnsupportedOperationException(getClass().getSimpleName()\n        + \" doesn't support deleteSnapshot\");\n  }\n\n  /**\n   * Set the source path to satisfy storage policy.\n   * @param path The source path referring to either a directory or a file.\n   * @throws IOException raised on errors performing I/O.\n   */\n  public void satisfyStoragePolicy(final Path path) throws IOException {\n    throw new UnsupportedOperationException(\n        getClass().getSimpleName() + \" doesn't support satisfyStoragePolicy\");\n  }\n\n  /**\n   * Set the storage policy for a given file or directory.\n   *\n   * @param path file or directory path.\n   * @param policyName the name of the target storage policy. The list","sourceCodeStart":1493,"sourceCodeEnd":1529,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java#L1493-L1529","documentation":"AbstractFileSystem.deleteSnapshot(Path, String) is a default stub that unconditionally throws UnsupportedOperationException prefixed with the subclass name. Deleting snapshots is HDFS-only functionality; the stub fires for every filesystem that does not override it. The error is about missing feature support, not about a missing snapshot.","triggerScenarios":"FileContext.deleteSnapshot(snapshotDir, name) on local or object-store schemes; cleanup jobs deleting expired snapshots after the mount table or defaultFS changed; snapshot retention tooling run generically over mixed-scheme paths.","commonSituations":"Retention/expiry scripts written for HDFS clusters are reused on environments whose storage is s3a/gs/local; viewfs mount entries pointing at non-HDFS stores; test harnesses with file:// defaultFS exercising the same code path.","solutions":["Run deleteSnapshot only against hdfs:// paths.","Use DistributedFileSystem.deleteSnapshot / `hdfs dfs -deleteSnapshot` for the HDFS contract.","Filter paths by URI scheme before invoking snapshot APIs.","Catch UnsupportedOperationException and treat deletion as done/skipped when snapshots cannot exist."],"exampleFix":"// before\nfc.deleteSnapshot(dir, \"expired-7\"); // throws on s3a://\n\n// after\nif (\"hdfs\".equals(dir.toUri().getScheme())) {\n  fc.deleteSnapshot(dir, \"expired-7\");\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.deleteSnapshot(dir, name);\n} catch (UnsupportedOperationException e) {\n  // no snapshot store: deletion is a no-op\n}","preventionTips":["Filter retention jobs by scheme before issuing snapshot deletions","Record which filesystem a snapshot was created on and delete only there"],"tags":["hadoop","filesystem","hdfs-snapshot","filecontext","unsupportedoperationexception"],"backgroundTag":"snapshots-unsupported","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}