{"record":{"id":"79ea7b28d8966ea0","repo":"GoogleContainerTools/jib","slug":"cannot-resolve-against-absolute-path-relativepa","errorCode":null,"errorMessage":"Cannot resolve against absolute Path: ${relativePath}","messagePattern":"Cannot resolve against absolute Path: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"jib-build-plan/src/main/java/com/google/cloud/tools/jib/api/buildplan/AbsoluteUnixPath.java","lineNumber":112,"sourceCode":"  public AbsoluteUnixPath resolve(RelativeUnixPath relativeUnixPath) {\n    int newSize = pathComponents.size() + relativeUnixPath.getRelativePathComponents().size();\n    List<String> newPathComponents = new ArrayList<>(newSize);\n\n    newPathComponents.addAll(pathComponents);\n    newPathComponents.addAll(relativeUnixPath.getRelativePathComponents());\n    return new AbsoluteUnixPath(newPathComponents);\n  }\n\n  /**\n   * Resolves this path against another relative path (by the name elements of {@code\n   * relativePath}).\n   *\n   * @param relativePath the relative path to resolve against\n   * @return a new {@link AbsoluteUnixPath} representing the resolved path\n   */\n  public AbsoluteUnixPath resolve(Path relativePath) {\n    if (relativePath.getRoot() != null) {\n      throw new IllegalArgumentException(\"Cannot resolve against absolute Path: \" + relativePath);\n    }\n\n    return AbsoluteUnixPath.fromPath(Paths.get(unixPath).resolve(relativePath));\n  }\n\n  /**\n   * Resolves this path against another relative Unix path in string form.\n   *\n   * @param relativeUnixPath the relative path to resolve against\n   * @return a new {@link AbsoluteUnixPath} representing the resolved path\n   */\n  public AbsoluteUnixPath resolve(String relativeUnixPath) {\n    return resolve(RelativeUnixPath.get(relativeUnixPath));\n  }\n\n  /**\n   * Returns the string form of the absolute Unix-style path.\n   *","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-build-plan/src/main/java/com/google/cloud/tools/jib/api/buildplan/AbsoluteUnixPath.java#L94-L130","documentation":"AbsoluteUnixPath.resolve() appends a relative path to this absolute path. Because the argument must be relative, it throws IllegalArgumentException when the given Path has a root (is absolute), since resolving against an absolute path would discard the base — likely indicating a caller mistake.","triggerScenarios":"Calling absolutePath.resolve(Paths.get(\"/opt/app\")) — i.e. passing a Path with a non-null root.","commonSituations":"Mixing up the order of arguments or reusing a container-absolute destination path where a relative sub-path was intended.","solutions":["Pass a relative Path (no leading slash / no root), e.g. Paths.get(\"app/libs\")","If the value is absolute, drop the resolve call and use AbsoluteUnixPath.get() or at() on the absolute path directly","Strip the root component if a relative sub-path is truly needed"],"exampleFix":"// before\nAbsoluteUnixPath p = appRoot.resolve(Paths.get(\"/app/libs\"));\n// after\nAbsoluteUnixPath p = appRoot.resolve(Paths.get(\"libs\"));","handlingStrategy":"validation","validationCode":"if (relativePath.getRoot() != null) throw new IllegalArgumentException(\"resolve() expects a relative path\");","typeGuard":"boolean isRelativePath(Path p) { return p != null && p.getRoot() == null; }","tryCatchPattern":"try { AbsoluteUnixPath p = base.resolve(rel); } catch (IllegalArgumentException e) { /* use the absolute path directly: AbsoluteUnixPath.fromPath(rel) */ }","preventionTips":["Only pass Paths built from relative strings to resolve()","Check getRoot() != null as an assertion in calling code","Use AbsoluteUnixPath.get()/at() when the path is already absolute"],"tags":["jib","path-validation","illegal-argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}