{"record":{"id":"67260f6b5b5ad254","repo":"apache/iceberg","slug":"neither-version-txt-nor-git-version-exists-67260f","errorCode":null,"errorMessage":"Neither version.txt nor git version exists","messagePattern":"Neither version\\.txt nor git version exists","errorType":"console","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"build.gradle","lineNumber":1243,"sourceCode":"      // bump the MINOR version and always set the PATCH version to 0\n      return matcher.group(1) + \".\" + (Integer.valueOf(matcher.group(2)) + 1) + \".0-SNAPSHOT\"\n    }\n    return version\n  } catch (Exception e) {\n    throw new Exception(\"Neither version.txt nor git version exists: \" + e.getMessage(), e)\n  }\n}\n\nString getJavadocVersion() {\n  if (versionFileExists()) {\n    return getVersionFromFile()\n  }\n\n  try {\n    // use the branch name in place of version in Javadoc\n    return versionDetails().branchName\n  } catch (NullPointerException e) {\n    throw new Exception(\"Neither version.txt nor git version exists\")\n  }\n}\n\napply from: 'jmh.gradle'\napply from: 'baseline.gradle'\napply from: 'deploy.gradle'\napply from: 'tasks.gradle'\n\nproject(':iceberg-bom') {\n  apply plugin: 'java-platform'\n\n  dependencies {\n    constraints {\n      // The Iceberg-Build builds for only one Scala version at a time, so the BOM would also\n      // only contain artifacts for that single Scala version. The following code ensures that\n      // the BOM references the artifacts for all Scala versions.\n      def sparkScalaPattern = ~\"(.*)-([0-9][.][0-9]+)_([0-9][.][0-9]+)\"\n      def sparkScalaVersions = [","sourceCodeStart":1225,"sourceCodeEnd":1261,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/build.gradle#L1225-L1261","documentation":"getJavadocVersion falls back to the git branch name for Javadoc versioning; if versionDetails() throws NullPointerException (no git metadata), it throws Exception stating that neither version.txt nor git version exists. The build environment lacks any version source.","triggerScenarios":"Generating Javadoc (or any task invoking getJavadocVersion) in a directory without .git and without version.txt, where versionDetails branchName lookup fails with NPE.","commonSituations":"Source archives without git metadata; CI checkouts with depth=1 and detached head lacking branch info; nightly builds in stripped-down workspaces.","solutions":["Ensure the workspace is a proper git checkout with branch information (unshallow if needed)","Provide version.txt so the version file path is used instead of git","Export CI branch info and ensure the gradle-git-version plugin can read it","Verify GIT_BRANCH/branch environment for CI shallow clones"],"exampleFix":"// before: git fetch --depth=1 (no branch info)\n// after\ngit fetch --unshallow && git checkout main","handlingStrategy":"validation","validationCode":"if [ ! -d .git ] && ! git rev-parse --abbrev-ref HEAD 2>/dev/null; then\n  echo \"Git branch info unavailable; provide version.txt\"; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid --depth=1 checkouts for builds needing version info","Provide version.txt as a fallback for non-git builds","Ensure CI exposes branch names to the build"],"tags":["gradle","javadoc","git"],"backgroundTag":"file-not-found","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}