{"record":{"id":"f48133ea443d1dd1","repo":"GoogleContainerTools/jib","slug":"octalpermissions-must-be-a-3-digit-octal-number-0","errorCode":null,"errorMessage":"octalPermissions must be a 3-digit octal number (000-777)","messagePattern":"octalPermissions must be a 3-digit octal number \\(000-777\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"jib-build-plan/src/main/java/com/google/cloud/tools/jib/api/buildplan/FilePermissions.java","lineNumber":73,"sourceCode":"    map.put(PosixFilePermission.GROUP_READ, 040);\n    map.put(PosixFilePermission.GROUP_WRITE, 020);\n    map.put(PosixFilePermission.GROUP_EXECUTE, 010);\n    map.put(PosixFilePermission.OTHERS_READ, 04);\n    map.put(PosixFilePermission.OTHERS_WRITE, 02);\n    map.put(PosixFilePermission.OTHERS_EXECUTE, 01);\n    PERMISSION_MAP = Collections.unmodifiableMap(map);\n  }\n\n  /**\n   * Creates a new {@link FilePermissions} from an octal string representation (e.g. \"123\", \"644\",\n   * \"755\", etc).\n   *\n   * @param octalPermissions the octal string representation of the permissions\n   * @return a new {@link FilePermissions} with the given permissions\n   */\n  public static FilePermissions fromOctalString(String octalPermissions) {\n    if (!octalPermissions.matches(OCTAL_PATTERN)) {\n      throw new IllegalArgumentException(\n          \"octalPermissions must be a 3-digit octal number (000-777)\");\n    }\n    return new FilePermissions(Integer.parseInt(octalPermissions, 8));\n  }\n\n  /**\n   * Creates a new {@link FilePermissions} from a set of {@link PosixFilePermission}.\n   *\n   * @param posixFilePermissions the set of {@link PosixFilePermission}\n   * @return a new {@link FilePermissions} with the given permissions\n   */\n  public static FilePermissions fromPosixFilePermissions(\n      Set<PosixFilePermission> posixFilePermissions) {\n    int permissionBits = 0;\n    for (PosixFilePermission permission : posixFilePermissions) {\n      permissionBits |= Objects.requireNonNull(PERMISSION_MAP.get(permission));\n    }\n    return new FilePermissions(permissionBits);","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-build-plan/src/main/java/com/google/cloud/tools/jib/api/buildplan/FilePermissions.java#L55-L91","documentation":"FilePermissions.fromOctalString() parses a 3-digit octal permission string like '644'. It throws IllegalArgumentException when the string does not match the octal pattern (three octal digits 0-7), because it cannot represent valid Unix file permissions otherwise.","triggerScenarios":"Calling fromOctalString(\"7777\"), fromOctalString(\"644 \"), fromOctalString(\"94\"), fromOctalString(\"abc\"), or null/empty input.","commonSituations":"Permissions read from Dockerfiles or config files in formats like '0644' (4 digits), 'rw-r--r--', or containing stray whitespace.","solutions":["Pass exactly three octal digits 0-7, e.g. \"644\" or \"755\"","Trim the string and strip a leading '0' or non-digit prefix if present","Convert symbolic permissions to octal before calling"],"exampleFix":"// before\nFilePermissions.fromOctalString(\"0644\");\n// after\nFilePermissions.fromOctalString(\"644\");","handlingStrategy":"validation","validationCode":"if (perm == null || !perm.trim().matches(\"[0-7]{3}\")) throw new IllegalArgumentException(\"permissions must be 3 octal digits\");","typeGuard":"boolean isOctalPermissionString(String s) { return s != null && s.matches(\"[0-7]{3}\"); }","tryCatchPattern":"try { FilePermissions p = FilePermissions.fromOctalString(perm); } catch (IllegalArgumentException e) { /* fall back to default 644 */ }","preventionTips":["Validate permission strings with regex ^[0-7]{3}$ at config load","Strip leading '0' from 4-digit Dockerfile-style modes before passing","Store permissions as integers (e.g. 420 for 0644) where possible"],"tags":["jib","file-permissions","validation"],"backgroundTag":"invalid-argument-format","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"}