{"id":"c1e0df0123666f22","repo":"apache/kafka","slug":"failed-to-check-public-api-errormessage","errorCode":null,"errorMessage":"Failed to check public API: {errorMessage}","messagePattern":"Failed to check public API: (.+?)","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"api-checker/gradle-plugins/src/main/java/org/apache/kafka/gradle/KafkaPublicApiCheckerTask.java","lineNumber":131,"sourceCode":"                if (unjustified > 0) {\n                    getLogger().warn(\"{} suppression(s) carry no reason — KIP-1265 requires a justification on every @SuppressKafkaInternalApiUsage\", unjustified);\n                }\n            }\n            if (!violations.isEmpty()) {\n                String message = String.format(\"Found %d public API violations. See report: %s\",\n                    violations.size(), report.getAbsolutePath());\n\n                if (failOnViolation.get()) {\n                    throw new GradleException(message);\n                } else {\n                    getLogger().warn(message);\n                }\n            } else {\n                getLogger().info(\"No public API violations found.\");\n            }\n\n        } catch (IOException e) {\n            throw new GradleException(\"Failed to check public API: \" + e.getMessage(), e);\n        }\n    }\n\n    private File getJavadocJarFile() {\n        if (!javadocJarPath.isPresent()) {\n            throw new GradleException(\"kafkaPublicApiChecker.javadocJarPath is not set. \"\n                    + \"Either configure it explicitly on the extension, or apply this plugin to a \"\n                    + \"project that defines a 'javadocJar' Jar task whose output the plugin can \"\n                    + \"wire automatically.\");\n        }\n        return javadocJarPath.get().getAsFile();\n    }\n\n    @Input\n    public Property<Boolean> getCheckerEnabled() {\n        return enabled;\n    }\n","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/apache/kafka/blob/c31c9215e131f8c17e79f8901b48c13ee6aa8e7a/api-checker/gradle-plugins/src/main/java/org/apache/kafka/gradle/KafkaPublicApiCheckerTask.java#L113-L149","documentation":"Wrapped I/O failure raised by KafkaPublicApiCheckerTask.checkPublicApi() when PublicApiChecker construction or checkPublicApiConsistency(jarFile) throws an IOException. The original IOException is the cause; its message is appended so the exact failing file (project jar, reference jar, or javadoc jar entry) is visible. This is an infrastructure error reading inputs, not a consistency violation.","triggerScenarios":"Line 130-131 in the catch (IOException) block. Triggers: a project/reference jar is corrupt or concurrently deleted while being scanned; the javadoc jar is a zip that fails to open (truncated download, partial write); a configured path is inaccessible due to permissions; the Gradle build cache returned a corrupt cached artifact.","commonSituations":"Concurrent builds mutating build/libs or the Gradle cache; an interrupted jar task leaving a partial jar; CI on a constrained filesystem (NFS, overlay with inode limits); disk-full truncating outputs; antivirus locking zip entries during read.","solutions":["Re-run after a clean: ./gradlew clean javadocJar kafkaPublicApiCheck --rerun-tasks to rule out partial outputs.","Inspect the IOException cause for the specific path that failed, then verify the file (ls -l, unzip -t <jar>, jar tf <jar>).","If the file is corrupt, delete it and the Gradle cache entry for that artifact and re-resolve: ./gradlew --refresh-dependencies.","Free disk space / fix permissions / stop concurrent daemons (./gradlew --stop) if the cause points at a transient OS-level failure.","On network-mounted filesystems, move build dir and Gradle cache to local storage."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check: report dir writable, javadoc jar and project jars readable\nval out = layout.buildDirectory.dir(\"reports\").get().asFile\ncheck(out.exists() || out.mkdirs()) { \"cannot create ${out.absolutePath}\" }","typeGuard":null,"tryCatchPattern":"try {\n    tasks.named<org.apache.kafka.gradle.KafkaPublicApiCheckerTask>(\"kafkaPublicApiChecker\").get().checkPublicApi()\n} catch (e: org.gradle.api.GradleException) {\n    if (e.message?.startsWith(\"Failed to check public API\") == true && e.cause is java.io.IOException) {\n        logger.warn(\"Public API check skipped (transient IO: ${e.cause?.message}); rerun.\")\n    } else {\n        throw e\n    }\n}","preventionTips":["Run the checker on a clean build dir; partially written javadoc/project jars from an interrupted build cause IOException.","Don't hold the javadoc jar or report file open in another process (IDE indexer, antivirus) while the task runs.","Keep the checker off network/remote paths; use local build/ output for both inputs and the report."],"tags":["gradle","kafka","api-checker","io","filesystem"],"analyzedSha":"c31c9215e131f8c17e79f8901b48c13ee6aa8e7a","analyzedAt":"2026-08-03T12:34:05.770Z","schemaVersion":2}