{"record":{"id":"faf1892b5137a7eb","repo":"elastic/elasticsearch","slug":"unnecessary-split-package-ignores-found","errorCode":null,"errorMessage":"Unnecessary split package ignores found","messagePattern":"Unnecessary split package ignores found","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditTask.java","lineNumber":294,"sourceCode":"\n                if (currentClasses == null) {\n                    LOGGER.error(\"Package is not split: \" + fqcn);\n                    filterErrorsFound = true;\n                } else {\n                    if (className.equals(\"*\")) {\n                        currentClasses.clear();\n                    } else if (currentClasses.remove(fqcn) == false) {\n                        LOGGER.error(\"Class does not exist: \" + fqcn);\n                        filterErrorsFound = true;\n                    }\n                    // cleanup if we have ignored the last class in a package\n                    if (currentClasses.isEmpty()) {\n                        splitPackages.remove(packageName);\n                    }\n                }\n            }\n            if (filterErrorsFound) {\n                throw new GradleException(\"Unnecessary split package ignores found\");\n            }\n        }\n\n        // TODO: want to read packages the same for src dirs and jars, but src dirs we also want the files in the src package dir\n        private static Set<String> readPackages(File classpathElement) {\n            Set<String> packages = new HashSet<>();\n            Consumer<Path> addClassPackage = p -> packages.add(getPackageName(p));\n\n            try {\n                if (classpathElement.isDirectory()) {\n                    walkJavaFiles(classpathElement.toPath(), \".class\", addClassPackage);\n                } else if (classpathElement.getName().endsWith(\".jar\")) {\n                    try (FileSystem jar = FileSystems.newFileSystem(classpathElement.toPath(), Map.of())) {\n                        for (Path root : jar.getRootDirectories()) {\n                            walkJavaFiles(root, \".class\", addClassPackage);\n                        }\n                    }\n                } else {","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditTask.java#L276-L312","documentation":"Thrown by SplitPackagesAuditTask after iterating the per-project split-package ignore list. The audit walks every class on the classpath and removes each ignored FQCN from currentClasses; if remove() returns false the FQCN was not actually present, so the ignore entry is stale and filterErrorsFound flips true. The build then aborts with this message because the ignore list references classes that no longer exist in the audited project.","triggerScenarios":"A project's split-package ignore configuration lists a fully-qualified class name that has been renamed, moved, or deleted since the ignore was added. Running the splitPackagesAudit precommit task (directly or as part of check/precommit) removes existing classes from the set and, when a listed ignore cannot be matched against any current class, records an error and throws.","commonSituations":"Refactoring or relocating a class that was previously excluded from the split-package audit; merging a PR that deletes/moves a class without updating the ignore list; stale ignore entries left after a dependency upgrade changes shaded class names.","solutions":["Locate the project's split-package ignore configuration (typically a splitPackagesAudit { ... } or ignore file referenced by the task) and remove the stale FQCN(s) that no longer exist.","Re-run the task with --info to surface the 'Class does not exist:' log lines logged just before the throw, which name each offending FQCN.","After editing, re-run ./gradlew :<project>:splitPackagesAudit (or the precommit task) to confirm the ignore list now matches reality."],"exampleFix":"// before (stale entry in ignore list)\nsplitPackagesAudit {\n  ignore 'com.example.OldClassName'\n}\n// after (remove the deleted/renamed class)\nsplitPackagesAudit {\n  // entry removed — class no longer exists in this project\n}","handlingStrategy":"validation","validationCode":"// Before the audit, verify every ignored FQCN still exists on the classpath\nSet<String> ignoreList = loadSplitPackageIgnores(); // from config\nSet<String> classesOnClasspath = collectFqcnFromCompiledOutput(projectOutputDir);\nSet<String> stale = new HashSet<>(ignoreList);\nstale.removeAll(classesOnClasspath);\nif (stale.isEmpty() == false) {\n    throw new IllegalStateException(\"Remove stale ignores before running audit: \" + stale);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the split-package ignore list as code: remove an ignore in the same PR that removes/renames the class.","Run the precommit task locally before pushing so stale ignores surface early.","Periodically grep ignore entries against the codebase and prune ones with zero matches."],"tags":["build","gradle","precommit","split-packages","stale-config"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}