{"record":{"id":"36bae3102b31a749","repo":"apache/hadoop","slug":"cannot-find-source-file","errorCode":null,"errorMessage":"Cannot find source file - {}","messagePattern":"Cannot find source 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":696,"sourceCode":"  }\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      }\n    }\n    // Invoke\n    RemoteMethod method = new RemoteMethod(\"concat\",\n        new Class<?>[] {String.class, String[].class},\n        targetDestination.getDest(), sourceDestinations);\n    rpcClient.invokeSingle(targetDestination, method, Void.class);\n  }\n\n  @Override","sourceCodeStart":678,"sourceCodeEnd":714,"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#L678-L714","documentation":"While resolving concat sources, RouterClientProtocol.concat() calls getFileRemoteLocation(src[i]) for every source file. A null result (file not found in any candidate subcluster) throws IOException('Cannot find source file - <src>'). concat requires the target and all sources to exist in the same nameservice, so the Router resolves each source up front and aborts on the first miss.","triggerScenarios":"hdfs dfs -concat <trg> <src1> <src2> via the Router where one source path does not exist, was deleted, or its mount entry changed; source path outside any mounted subtree so resolution yields no locations.","commonSituations":"Race where a concurrent job deletes/appends a source between listing and concat; wrong relative path (missing mount prefix); mount table updated so source paths resolve elsewhere.","solutions":["List every source path through the Router (hdfs dfs -ls) and fix/remove missing ones before concat","Ensure source paths are under the same mount as the target and correctly namespaced","Retry if a transient rename/delete caused the miss"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// All sources must exist before concat\nfor (String s : srcs) {\n  if (clientProtocol.getFileInfo(s) == null) {\n    throw new FileNotFoundException(\"concat source missing: \" + s);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  clientProtocol.concat(trg, srcs);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Cannot find source file\")) {\n    // drop/recreate the missing source, or re-list and rebuild the source list\n  } else { throw e; }\n}","preventionTips":["Validate all source paths exist immediately before concat","Avoid concurrent deletes of files being concatenated"],"tags":["hdfs","router-based-federation","concat","file-not-found","validation"],"backgroundTag":"path-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}