{"record":{"id":"efcb42b164d2418e","repo":"GoogleContainerTools/jib","slug":"path-does-not-start-with-forward-slash-unix","errorCode":null,"errorMessage":"Path does not start with forward slash (/): ${unixPath}","messagePattern":"Path does not start with forward slash \\(/\\): (.+?)","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":45,"sourceCode":"/**\n * Represents a Unix-style path in absolute form (containing all path components relative to the\n * file system root {@code /}).\n *\n * <p>This class is immutable and thread-safe.\n */\n@Immutable\npublic class AbsoluteUnixPath {\n\n  /**\n   * Gets a new {@link AbsoluteUnixPath} from a Unix-style path string. The path must begin with a\n   * forward slash ({@code /}).\n   *\n   * @param unixPath the Unix-style path string in absolute form\n   * @return a new {@link AbsoluteUnixPath}\n   */\n  public static AbsoluteUnixPath get(String unixPath) {\n    if (!unixPath.startsWith(\"/\")) {\n      throw new IllegalArgumentException(\"Path does not start with forward slash (/): \" + unixPath);\n    }\n\n    return new AbsoluteUnixPath(UnixPathParser.parse(unixPath));\n  }\n\n  /**\n   * Gets a new {@link AbsoluteUnixPath} from a {@link Path}. The {@code path} must be absolute\n   * (indicated by a non-null {@link Path#getRoot}).\n   *\n   * @param path the absolute {@link Path} to convert to an {@link AbsoluteUnixPath}.\n   * @return a new {@link AbsoluteUnixPath}\n   */\n  public static AbsoluteUnixPath fromPath(Path path) {\n    if (path.getRoot() == null) {\n      throw new IllegalArgumentException(\n          \"Cannot create AbsoluteUnixPath from non-absolute Path: \" + path);\n    }\n","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-build-plan/src/main/java/com/google/cloud/tools/jib/api/buildplan/AbsoluteUnixPath.java#L27-L63","documentation":"AbsoluteUnixPath represents a Unix path that must be absolute (start with '/'). The get() factory method validates this and throws IllegalArgumentException when the given string is relative or empty of a leading slash, because Jib container paths (like appRoot and layer extraction targets) must be container-absolute.","triggerScenarios":"Calling AbsoluteUnixPath.get() with a string that does not start with '/', e.g. get(\"app/libs\") or get(\"\").","commonSituations":"Config values like --app-root, target paths, or layer destination paths read from YAML/properties/user input that omit the leading slash (e.g. 'app' instead of '/app').","solutions":["Prefix the path with a forward slash before passing it to AbsoluteUnixPath.get()","Validate user/config-supplied paths with path.startsWith(\"/\") beforehand","If the path comes from a Path object, use AbsoluteUnixPath.fromPath() with an absolute Path instead"],"exampleFix":"// before\nAbsoluteUnixPath appRoot = AbsoluteUnixPath.get(\"app\");\n// after\nAbsoluteUnixPath appRoot = AbsoluteUnixPath.get(\"/app\");","handlingStrategy":"validation","validationCode":"if (path == null || !path.startsWith(\"/\")) throw new IllegalArgumentException(\"appRoot must be absolute: \" + path);","typeGuard":"boolean isAbsoluteUnixPath(String p) { return p != null && p.startsWith(\"/\"); }","tryCatchPattern":"try { AbsoluteUnixPath p = AbsoluteUnixPath.get(path); } catch (IllegalArgumentException e) { /* treat path as relative: p = AbsoluteUnixPath.get(\"/\" + path); */ }","preventionTips":["Always write container paths with a leading slash in configs","Normalize with path.startsWith(\"/\") ? path : \"/\" + path before calling get()","Prefer AbsoluteUnixPath.fromPath() with absolute Path objects over raw strings"],"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-14T00:17:10.932Z"}