{"record":{"id":"7d42d5fe3a49038e","repo":"nathanmarz/storm","slug":"path-is-not-a-valid-version","errorCode":null,"errorMessage":"${path} is not a valid version","messagePattern":"(.+?) is not a valid version","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"storm-core/src/jvm/backtype/storm/utils/VersionedStore.java","lineNumber":152,"sourceCode":"    public List<Long> getAllVersions() throws IOException {\n        List<Long> ret = new ArrayList<Long>();\n        for(String s: listDir(_root)) {\n            if(s.endsWith(FINISHED_VERSION_SUFFIX)) {\n                ret.add(validateAndGetVersion(s));\n            }\n        }\n        Collections.sort(ret);\n        Collections.reverse(ret);\n        return ret;\n    }\n\n    private String tokenPath(long version) {\n        return new File(_root, \"\" + version + FINISHED_VERSION_SUFFIX).getAbsolutePath();\n    }\n\n    private long validateAndGetVersion(String path) {\n        Long v = parseVersion(path);\n        if(v==null) throw new RuntimeException(path + \" is not a valid version\");\n        return v;\n    }\n\n    private Long parseVersion(String path) {\n        String name = new File(path).getName();\n        if(name.endsWith(FINISHED_VERSION_SUFFIX)) {\n            name = name.substring(0, name.length()-FINISHED_VERSION_SUFFIX.length());\n        }\n        try {\n            return Long.parseLong(name);\n        } catch(NumberFormatException e) {\n            return null;\n        }\n    }\n\n    private void createNewFile(String path) throws IOException {\n        new File(path).createNewFile();\n    }","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/nathanmarz/storm/blob/cdb116e942666973bc4eaa0df098d5bab82739e7/storm-core/src/jvm/backtype/storm/utils/VersionedStore.java#L134-L170","documentation":"VersionedStore.validateAndGetVersion parses a version number out of a version directory path. If the file name does not end with the finished-version suffix (or otherwise yields no parsable Long), it throws RuntimeException stating the path is not a valid version.","triggerScenarios":"Calling failVersion(path), version(path), or getAllVersions() over a directory containing files/dirs under _root that are not version directories (e.g. temp dirs, checkpoint metadata, human-created files), so parseVersion returns null.","commonSituations":"Users placed unrelated files in the versioned store root; an interrupted createVersion left a non-conforming temp directory; a path built manually without the FINISHED_VERSION_SUFFIX was passed to failVersion.","solutions":["Pass only paths returned by createVersion / version() — never arbitrary files in the store root.","Remove non-version files/directories from the store root directory.","Inspect the directory: only names matching '<number>.finished' (finished suffix) are valid versions; rename or delete malformed leftovers from crashed writes.","Catch RuntimeException around getAllVersions()/failVersion when the store dir may be dirty, and skip invalid entries."],"exampleFix":"// before\nstore.failVersion(someDirPath); // someDirPath lacks the finished suffix\n// after\nif (new File(path).getName().endsWith(FINISHED_VERSION_SUFFIX_PATTERN)) {\n    store.failVersion(path);\n} else {\n    LOG.warn(\"Ignoring non-version path: \" + path);\n}","handlingStrategy":"validation","validationCode":"String name = new File(path).getName();\nif (!name.matches(\"\\\\d+\" + FINISHED_VERSION_SUFFIX)) {\n    throw new IllegalArgumentException(\"Not a version dir: \" + path);\n}","typeGuard":"boolean isValidVersionPath(String path) {\n    String name = new File(path).getName();\n    return name.endsWith(\".finished\") && name.replace(\".finished\", \"\").matches(\"\\\\d+\");\n}","tryCatchPattern":"try {\n    long v = store.version(path);\n} catch (RuntimeException e) {\n    LOG.warn(\"Skipping invalid version path \" + path);\n}","preventionTips":["Keep unrelated files out of the versioned store root","Only pass paths produced by createVersion()/version() to failVersion","Periodically clean temp/aborted dirs left by crashed writers"],"tags":["java","storage","path-validation","storm"],"backgroundTag":"invalid-identifier-format","analyzedSha":"cdb116e942666973bc4eaa0df098d5bab82739e7","analyzedAt":"2026-09-12T14:30:00.714Z","contentChangedAt":"2026-09-12T14:30:00.714Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}