{"record":{"id":"c460ec15ad10361c","repo":"apache/dolphinscheduler","slug":"schemaversion-or-version-is-empty","errorCode":null,"errorMessage":"schemaVersion or version is empty","messagePattern":"schemaVersion or version is empty","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/utils/SchemaUtils.java","lineNumber":84,"sourceCode":"\n                return -1;\n            } catch (Exception e) {\n                log.error(e.getMessage(), e);\n                throw new RuntimeException(e);\n            }\n        }).collect(Collectors.toList());\n    }\n\n    /**\n     * Determine whether schemaVersion is higher than version\n     *\n     * @param schemaVersion schema version\n     * @param version version\n     * @return Determine whether schemaVersion is higher than version\n     */\n    public static boolean isAGreatVersion(String schemaVersion, String version) {\n        if (Strings.isNullOrEmpty(schemaVersion) || Strings.isNullOrEmpty(version)) {\n            throw new RuntimeException(\"schemaVersion or version is empty\");\n        }\n\n        String[] schemaVersionArr = schemaVersion.split(\"\\\\.\");\n        String[] versionArr = version.split(\"\\\\.\");\n        int arrLength = Math.min(schemaVersionArr.length, versionArr.length);\n        for (int i = 0; i < arrLength; i++) {\n            if (Integer.parseInt(schemaVersionArr[i]) > Integer.parseInt(versionArr[i])) {\n                return true;\n            } else if (Integer.parseInt(schemaVersionArr[i]) < Integer.parseInt(versionArr[i])) {\n                return false;\n            }\n        }\n\n        // If the version and schema version is the same from 0 up to the arrlength-1 element,whoever has a larger\n        // arrLength has a larger version number\n        return schemaVersionArr.length > versionArr.length;\n    }\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/utils/SchemaUtils.java#L66-L102","documentation":"SchemaUtils.isAGreatVersion validates that both version strings are non-empty before comparing them component-wise. If either the schema version (from version metadata) or the target version string is null/empty, it throws this RuntimeException instead of comparing. It is a guard against corrupted or missing version information during upgrade checks.","triggerScenarios":"Calling isAGreatVersion(schemaVersion, version) with a null/empty argument, typically when the schema_version row in the metadata DB is missing/empty or a version string constant was not resolved.","commonSituations":"Upgrading a DB whose version table was never populated or was truncated; passing an unconfigured/unresolved version variable; manually editing version metadata.","solutions":["Verify the version info in the metadata DB (schema_version) is populated","Ensure the caller passes the correct, non-empty target version string","Restore correct version metadata from a backup before re-running the upgrade tool","Add a pre-check that validates version strings before invoking SchemaUtils"],"exampleFix":"// before\nSchemaUtils.isAGreatVersion(currentVersion, null);\n// after\nif (Strings.isNullOrEmpty(currentVersion) || Strings.isNullOrEmpty(targetVersion)) {\n    throw new IllegalStateException(\"version metadata missing: current=\" + currentVersion + \", target=\" + targetVersion);\n}\nboolean greater = SchemaUtils.isAGreatVersion(currentVersion, targetVersion);","handlingStrategy":"validation","validationCode":"import org.apache.hbase.thirdparty.com.google.common.base.Strings; // or guava\nif (Strings.isNullOrEmpty(schemaVersion) || Strings.isNullOrEmpty(targetVersion)) {\n    throw new IllegalStateException(\"Version metadata incomplete: schemaVersion=\" + schemaVersion + \", version=\" + targetVersion);\n}\nSchemaUtils.isAGreatVersion(schemaVersion, targetVersion);","typeGuard":"private static boolean hasVersion(String v) {\n    return v != null && !v.trim().isEmpty();\n}","tryCatchPattern":"try {\n    boolean greater = SchemaUtils.isAGreatVersion(schemaVersion, targetVersion);\n} catch (RuntimeException e) {\n    if (\"schemaVersion or version is empty\".equals(e.getMessage())) {\n        log.error(\"Version metadata missing; check schema_version table and configured version\", e);\n    } else { throw e; }\n}","preventionTips":["Verify the version row exists in the metadata DB before upgrade checks","Never pass unresolved/unconfigured version variables","Validate version strings at config load time"],"tags":["versioning","validation","upgrade"],"backgroundTag":"empty-required-field","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}