{"record":{"id":"6a8de53889bd7ac0","repo":"apache/hadoop","slug":"source-s-is-directory-and-destination-s-is-f","errorCode":null,"errorMessage":"Source '%s' is directory and destination '%s' is file","messagePattern":"Source '(.+?)' is directory and destination '(.+?)' is file","errorType":"exception","errorClass":"FileAlreadyExistsException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/CopyFromLocalOperation.java","lineNumber":339,"sourceCode":"   *\n   * @param dest      - Destination path\n   * @param src       - Source file\n   * @param overwrite - Should source overwrite destination\n   * @throws PathExistsException - If the destination path exists and no\n   *                             overwrite flag is set\n   * @throws FileAlreadyExistsException - If source is file and destination is path\n   */\n  private void checkDestination(\n      Path dest,\n      File src,\n      boolean overwrite) throws PathExistsException,\n      FileAlreadyExistsException {\n    if (!getDestStatus().isPresent()) {\n      return;\n    }\n\n    if (src.isDirectory() && getDestStatus().get().isFile()) {\n      throw new FileAlreadyExistsException(\n          \"Source '\" + src.getPath() + \"' is directory and \" +\n              \"destination '\" + dest + \"' is file\");\n    }\n\n    if (!overwrite) {\n      throw new PathExistsException(dest + \" already exists\");\n    }\n  }\n\n  /**\n   * Get the final path of a source file with regards to its destination.\n   *\n   * @param src - source path\n   * @return - the final path for the source file to be uploaded to\n   * @throws PathIOException - if a relative path can't be created\n   */\n  private Path getFinalPath(Path src) throws PathIOException {\n    URI currentSrcUri = src.toUri();","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/CopyFromLocalOperation.java#L321-L357","documentation":"Error \"Source '%s' is directory and destination '%s' is file\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/CopyFromLocalOperation.java:339 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a destination that is a directory or does not exist; you cannot copy a directory onto an existing file."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}