{"record":{"id":"c9bbbd72a8958c6b","repo":"apache/hadoop","slug":"no-filename-header-provided-by-server","errorCode":null,"errorMessage":"No filename header provided by server","messagePattern":"No filename header provided by server","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Util.java","lineNumber":215,"sourceCode":"   * the specified destination storage location.\n   */\n  public static MD5Hash receiveFile(String url, List<File> localPaths,\n      Storage dstStorage, boolean getChecksum, long advertisedSize,\n      MD5Hash advertisedDigest, String fsImageName, InputStream stream,\n      DataTransferThrottler throttler) throws\n      IOException {\n    long startTime = Time.monotonicNow();\n    Map<FileOutputStream, File> streamPathMap = new HashMap<>();\n    StringBuilder xferStats = new StringBuilder();\n    double xferCombined = 0;\n    if (localPaths != null) {\n      // If the local paths refer to directories, use the server-provided header\n      // as the filename within that directory\n      List<File> newLocalPaths = new ArrayList<>();\n      for (File localPath : localPaths) {\n        if (localPath.isDirectory()) {\n          if (fsImageName == null) {\n            throw new IOException(\"No filename header provided by server\");\n          }\n          newLocalPaths.add(new File(localPath, fsImageName));\n        } else {\n          newLocalPaths.add(localPath);\n        }\n      }\n      localPaths = newLocalPaths;\n    }\n\n\n    long received = 0;\n    MessageDigest digester = null;\n    if (getChecksum) {\n      digester = MD5Hash.getDigester();\n      stream = new DigestInputStream(stream, digester);\n    }\n    boolean finishedReceiving = false;\n    int num = 1;","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Util.java#L197-L233","documentation":"Util.receiveFile writes the downloaded image into each localPath; when a localPath is an existing directory, the target filename must come from the server's fsimage name header (ImageServlet.HADOOP_IMAGE_EDITS_HEADER). If that header is null the file cannot be placed, so the download fails fast.","triggerScenarios":"Invoking Util.doGetUrl/receiveFile with localPaths that are directories while the server response omits the image-edits name header — e.g. a test or custom servlet in front of GetImageServlet that forwards the body but not the custom header.","commonSituations":"Custom tooling or tests that call these internals directly with a storage directory instead of a file path; a proxy stripping non-standard headers (HADOOP_IMAGE_EDITS_HEADER is custom, proxies may drop it).","solutions":["Pass explicit file paths in localPaths instead of directories, so the header is not needed","Ensure the endpoint is the stock GetImageServlet, which always sets the header","If a proxy is in the path, allow the custom HADOOP_IMAGE_EDITS_HEADER through"],"exampleFix":"// before\nList<File> localPaths = Collections.singletonList(new File(\"/data/nn/current\")); // directory\nUtil.doGetUrl(url, localPaths, storage, true, 0, null);\n\n// after\nList<File> localPaths = Collections.singletonList(\n    new File(\"/data/nn/current/fsimage_0000000000000000123\")); // explicit file\nUtil.doGetUrl(url, localPaths, storage, true, 0, null);","handlingStrategy":"validation","validationCode":"// Avoid needing the server-side filename header at all\nfor (File p : localPaths) {\n  if (p.isDirectory()) {\n    throw new IllegalArgumentException(\n        \"Pass an explicit file path, not a directory: \" + p\n            + \" (server filename header may be absent)\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  Util.doGetUrl(url, localPaths, storage, false, timeoutMs, throttler);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"No filename header\")) {\n    // retry with explicit file targets instead of directories\n  }\n  throw e;\n}","preventionTips":["Always pass concrete file paths to image download helpers","If a proxy sits in the path, whitelist custom HADOOP_* headers"],"tags":["hdfs","fsimage","transfer","http-header","local-path"],"backgroundTag":"missing-http-header","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}