{"record":{"id":"6e50e7091c8bc348","repo":"apache/hadoop","slug":"cannot-parse-uri-s","errorCode":null,"errorMessage":"Cannot parse URI %s","messagePattern":"Cannot parse URI (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/commit/files/SinglePendingCommit.java","lineNumber":300,"sourceCode":"\n  @Override\n  public IOStatistics save(final FileSystem fs,\n      final Path path,\n      final JsonSerialization<SinglePendingCommit> serializer) throws IOException {\n    return saveFile(fs, path, this, serializer, true);\n  }\n\n  /**\n   * Build the destination path of the object.\n   * @return the path\n   * @throws IllegalStateException if the URI is invalid\n   */\n  public Path destinationPath() {\n    Preconditions.checkState(StringUtils.isNotEmpty(uri), \"Empty uri\");\n    try {\n      return new Path(new URI(uri));\n    } catch (URISyntaxException e) {\n      throw new IllegalStateException(\"Cannot parse URI \" + uri);\n    }\n  }\n\n  /**\n   * Get the number of etags.\n   * @return the size of the etag list.\n   */\n  public int getPartCount() {\n    return etags.size();\n  }\n\n  /**\n   * Iterate over the etags.\n   * @return an iterator.\n   */\n  @Override\n  public Iterator<UploadEtag> iterator() {\n    return etags.iterator();","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/commit/files/SinglePendingCommit.java#L282-L318","documentation":"IllegalStateException from SinglePendingCommit.destinationPath() when the record's 'uri' text cannot be parsed by java.net.URI. Each SinglePendingCommit in a pendingset-*.json file stores the destination object URI as a string; destinationPath() first asserts the uri is non-empty (Guava 'Empty uri' check) and then converts it to a Hadoop Path. Malformed URIs (unencoded spaces, bad characters, relative references) throw URISyntaxException, which is rethrown as this IllegalStateException. Note the cause is not chained, so only the message shows the offending uri.","triggerScenarios":"Committing a job whose pending commit records contain a uri like 's3a://bucket/my file' (unencoded space) or 'bucket/key' (no scheme); destinationPath() is called while loading pendingsets during commitJob or in tooling that audits pending commits.","commonSituations":"The staging/magic task wrote a destPath that was not fully qualified or not URI-encoded; the pendingset JSON was hand-edited or corrupted; versions of the writer and reader disagree on how the uri field was serialized.","solutions":["Inspect the uri field of the pendingset-*.json files under the job's staging/magic output directory to find the malformed entry","Abort the job commit (committer cleanup / delete the output path) and rerun the job so clean pendingsets are produced","Ensure destPath passed to uploadFileToPendingCommit is a fully qualified s3a:// path (Path.makeQualified) with URI-safe encoding","If the JSON must be repaired manually, percent-encode unsafe characters in the uri field"],"exampleFix":"// before\nPath dest = new Path(\"bucket/out/part-00000\"); // relative, unqualified\n\n// after\nPath dest = new Path(\"s3a://bucket/out/part-00000\").makeQualified(fs.getUri(), fs.getWorkingDirectory());","handlingStrategy":"try-catch","validationCode":"for (SinglePendingCommit c : pendingSet.commits()) {\n  try {\n    new java.net.URI(c.uri()); // cheap pre-parse\n  } catch (java.net.URISyntaxException bad) {\n    LOG.error(\"Bad pending commit uri: {}\", c.uri());\n    return false; // refuse to commit this pendingset\n  }\n}\nreturn true;","typeGuard":null,"tryCatchPattern":"try {\n  Path dest = commit.destinationPath();\n} catch (IllegalStateException e) {\n  // message contains the offending uri; the URISyntaxException cause is NOT chained\n  throw new IOException(\"Corrupt pending commit record: \" + e.getMessage(), e);\n}","preventionTips":["Always fully qualify (makeQualified) destination paths before handing them to committer APIs","Percent-encode any user-derived fragment that ends up in output filenames","Treat hand-edited pendingset JSON as unsupported: rerun the job instead of patching files"],"tags":["s3a","committer","uri-parsing","pendingset"],"backgroundTag":"invalid-uri","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}