{"record":{"id":"03f1fe4d5095535d","repo":"xpipe-io/xpipe","slug":"trimmed-entry-name-is-empty","errorCode":null,"errorMessage":"Trimmed entry name is empty","messagePattern":"Trimmed entry name is empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/xpipe/app/util/StorePath.java","lineNumber":52,"sourceCode":"     * Creates a new store path.\n     *\n     * @throws IllegalArgumentException if any name is not valid\n     */\n    public static StorePath create(String... names) {\n        if (names == null) {\n            throw new IllegalArgumentException(\"Names are null\");\n        }\n\n        if (Arrays.stream(names).anyMatch(s -> s == null)) {\n            throw new IllegalArgumentException(\"Name is null\");\n        }\n\n        if (Arrays.stream(names).anyMatch(s -> s.contains(\"\" + SEPARATOR))) {\n            throw new IllegalArgumentException(\"Separator character \" + SEPARATOR + \" is not allowed in the names\");\n        }\n\n        if (Arrays.stream(names).anyMatch(s -> s.strip().length() == 0)) {\n            throw new IllegalArgumentException(\"Trimmed entry name is empty\");\n        }\n\n        return new StorePath(Arrays.stream(names).toList());\n    }\n\n    /**\n     * Creates a new store path from a string representation.\n     *\n     * @param s the string representation, must be not null and fulfill certain requirements\n     * @throws IllegalArgumentException if the string is not valid\n     */\n    public static StorePath fromString(String s) {\n        if (s == null) {\n            throw new IllegalArgumentException(\"String is null\");\n        }\n\n        var split = s.split(String.valueOf(SEPARATOR), -1);\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/xpipe-io/xpipe/blob/d85ca821baa46092a320ebb13546d7240adb74f8/app/src/main/java/io/xpipe/app/util/StorePath.java#L34-L70","documentation":"StorePath.create(...) builds a store path from one or more name segments. The library throws this IllegalArgumentException when any provided name is null, whitespace-only, or otherwise empty after stripping, because a path segment cannot be blank. It keeps store paths from silently containing empty components that would break serialization and matching.","triggerScenarios":"Calling StorePath.create(null), create(\"\"), create(\" \"), or any varargs call where at least one name has strip().length() == 0.","commonSituations":"Passing user-entered store names straight into create() without trimming; a split/generation routine producing empty trailing segments; optional config fields left blank and forwarded as a name.","solutions":["Trim and check each name before calling: if (name == null || name.strip().isEmpty()) skip or fail early.","Filter out blank segments: Arrays.stream(rawNames).map(String::strip).filter(s -> !s.isEmpty()).toArray(String[]::new) and pass that.","Make sure no name contains the SEPARATOR character, otherwise the adjacent separator check throws instead."],"exampleFix":"// before\nStorePath p = StorePath.create(userInput);\n// after\nif (userInput != null && !userInput.strip().isEmpty()) {\n    StorePath p = StorePath.create(userInput.strip());\n} else {\n    throw new IllegalArgumentException(\"Store name required\");\n}","handlingStrategy":"validation","validationCode":"public static boolean isValidName(String s) {\n    return s != null && !s.strip().isEmpty() && s.indexOf(StorePath.SEPARATOR) < 0;\n}","typeGuard":null,"tryCatchPattern":"try {\n    StorePath p = StorePath.create(name);\n} catch (IllegalArgumentException e) {\n    // handle blank or separator-containing name\n}","preventionTips":["Trim all user-supplied names before creating a StorePath","Check for the SEPARATOR character in every segment","Filter out empty segments when deriving names from splits"],"tags":["java","argument-validation","store-path"],"backgroundTag":"empty-required-field","analyzedSha":"d85ca821baa46092a320ebb13546d7240adb74f8","analyzedAt":"2026-09-06T14:30:08.251Z","contentChangedAt":"2026-09-06T14:30:08.251Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}