{"record":{"id":"bf859110bcec4fe0","repo":"apache/hadoop","slug":"cannot-find-target-file","errorCode":null,"errorMessage":"Cannot find target file - {}","messagePattern":"Cannot find target file - (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java","lineNumber":687,"sourceCode":"      if (locs.size() != srcLocations.size()) {\n        throw new IOException(\"Rename of \" + src + \" to \" + dst + \" is not\"\n            + \" allowed. The number of remote locations for both source and\"\n            + \" target should be same.\");\n      }\n      rpcClient.invokeConcurrent(locs, method);\n    } else {\n      rpcClient.invokeSequential(locs, method, null, null);\n    }\n  }\n\n  @Override\n  public void concat(String trg, String[] src) throws IOException {\n    rpcServer.checkOperation(NameNode.OperationCategory.WRITE);\n\n    // Concat only effects when all files in the same namespace.\n    RemoteLocation targetDestination = getFileRemoteLocation(trg);\n    if (targetDestination == null) {\n      throw new IOException(\"Cannot find target file - \" + trg);\n    }\n    String targetNameService = targetDestination.getNameserviceId();\n\n    String[] sourceDestinations = new String[src.length];\n    for (int i = 0; i < src.length; i++) {\n      String sourceFile = src[i];\n      RemoteLocation srcLocation = getFileRemoteLocation(sourceFile);\n      if (srcLocation == null) {\n        throw new IOException(\"Cannot find source file - \" + sourceFile);\n      }\n      sourceDestinations[i] = srcLocation.getDest();\n\n      if (!targetNameService.equals(srcLocation.getNameserviceId())) {\n        throw new IOException(\"Cannot concatenate source file \" + sourceFile\n            + \" because it is located in a different namespace\" + \" with nameservice \"\n            + srcLocation.getNameserviceId() + \" from the target file with nameservice \"\n            + targetNameService);\n      }","sourceCodeStart":669,"sourceCodeEnd":705,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java#L669-L705","documentation":"concat() through the Router first resolves the target path with getFileRemoteLocation(trg), which returns the single remote location or, when ambiguous, probes candidates with getFileInfo. If it cannot find any location where the target exists (locations list empty or all getFileInfo probes null), it returns null and concat fails with IOException('Cannot find target file - <trg>'). Effectively: the target file does not exist in any subcluster behind the Router.","triggerScenarios":"hdfs dfs -concat through the Router with a target path that does not exist; target exists only under a mount whose resolution returns multiple locations and none report the file (propagation delay or wrong mount); target path outside any mount (returns empty location list).","commonSituations":"Concat before the target file was created or after it was deleted; mount table changed so the old target path no longer maps to the owning nameservice; typo in the target path.","solutions":["Verify the target exists through the Router: hdfs dfs -ls <trg>; create it if missing","Check the mount table maps <trg> to the nameservice where the file actually lives","Run the concat directly against the owning nameservice if Router-side ambiguity persists"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify target exists through the Router before concat\nHdfsFileStatus st = clientProtocol.getFileInfo(trg);\nif (st == null) {\n  throw new FileNotFoundException(\"concat target missing: \" + trg);\n}","typeGuard":null,"tryCatchPattern":"try {\n  clientProtocol.concat(trg, srcs);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Cannot find target file\")) {\n    // create/locate the target in the correct namespace, then retry\n  } else { throw e; }\n}","preventionTips":["Existence-check the target before invoking concat","Ensure the target's path resolves through a mount entry pointing at its real namespace"],"tags":["hdfs","router-based-federation","concat","file-not-found","mount-table"],"backgroundTag":"path-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}