{"record":{"id":"c2b5aeca288033f6","repo":"elastic/elasticsearch","slug":"invalid-platform-valid-values-linux-macos","errorCode":null,"errorMessage":"invalid platform: {}, valid values: [linux, macos, windows]","messagePattern":"invalid platform: (.+?), valid values: \\[linux, macos, windows\\]","errorType":"validation","errorClass":"PolicyValidationException","httpStatus":null,"severity":"error","filePath":"libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/entitlements/FilesEntitlement.java","lineNumber":176,"sourceCode":"    private static Mode parseMode(String mode) {\n        if (mode.equals(\"read\")) {\n            return Mode.READ;\n        } else if (mode.equals(\"read_write\")) {\n            return Mode.READ_WRITE;\n        } else {\n            throw new PolicyValidationException(\"invalid mode: \" + mode + \", valid values: [read, read_write]\");\n        }\n    }\n\n    private static Platform parsePlatform(String platform) {\n        if (platform.equals(\"linux\")) {\n            return Platform.LINUX;\n        } else if (platform.equals(\"macos\")) {\n            return Platform.MACOS;\n        } else if (platform.equals(\"windows\")) {\n            return Platform.WINDOWS;\n        } else {\n            throw new PolicyValidationException(\"invalid platform: \" + platform + \", valid values: [linux, macos, windows]\");\n        }\n    }\n\n    private static BaseDir parseBaseDir(String baseDir) {\n        return switch (baseDir) {\n            case \"config\" -> BaseDir.CONFIG;\n            case \"data\" -> BaseDir.DATA;\n            case \"home\" -> BaseDir.USER_HOME;\n            case \"shared_data\" -> BaseDir.SHARED_DATA;\n            // it would be nice to limit this to just ES modules, but we don't have a way to plumb that through to here\n            // however, we still don't document in the error case below that shared_repo and shared_data is valid\n            case \"shared_repo\" -> BaseDir.SHARED_REPO;\n            default -> throw new PolicyValidationException(\n                \"invalid relative directory: \" + baseDir + \", valid values: [config, data, home]\"\n            );\n        };\n    }\n","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/entitlements/FilesEntitlement.java#L158-L194","documentation":"Thrown by FilesEntitlement.parsePlatform when the `platform` field on a files-entitlement entry is anything other than \"linux\", \"macos\", or \"windows\". Platform optionally restricts an entry to a single OS; an unknown value cannot be matched at runtime.","triggerScenarios":"A files-entitlement entry includes a `platform` key whose value is not in the allowed set (e.g. \"osx\", \"mac\", \"win\", \"unix\", or \"Linux\" with wrong casing).","commonSituations":"Using colloquial OS names (osx/mac) instead of the canonical literal; assuming case-insensitivity; copy-pasting from documentation written for a different schema; mis-typing the platform literal.","solutions":["Use \"linux\", \"macos\", or \"windows\" exactly (lowercase).","If you want the entry to apply to all platforms, omit the `platform` key entirely rather than passing a sentinel like \"all\"."],"exampleFix":"// before\n{ \"relative_path\": \"logs\", \"relative_to\": \"home\", \"mode\": \"read\", \"platform\": \"osx\" }\n\n// after\n{ \"relative_path\": \"logs\", \"relative_to\": \"home\", \"mode\": \"read\", \"platform\": \"macos\" }","handlingStrategy":"validation","validationCode":"private static final Set<String> ALLOWED_PLATFORMS = Set.of(\"linux\", \"macos\", \"windows\");\npublic static void validatePlatform(String p) {\n    if (p != null && !ALLOWED_PLATFORMS.contains(p)) {\n        throw new IllegalArgumentException(\"platform must be one of \" + ALLOWED_PLATFORMS);\n    }\n}","typeGuard":"public static boolean isValidPlatform(String p) {\n    return p == null || Set.of(\"linux\",\"macos\",\"windows\").contains(p);\n}","tryCatchPattern":null,"preventionTips":["Omit `platform` entirely when the entry should apply to all OSes.","Never use osx/mac/win — use the canonical lowercase literal.","Add a policy JSON Schema check covering enum fields."],"tags":["entitlements","files","policy","platform","validation"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}