{"record":{"id":"52fa94d30dfa5479","repo":"apple/pkl","slug":"packagealreadypublishedwithdifferentcontents","errorCode":"packageAlreadyPublishedWithDifferentContents","errorMessage":"ErrorMessages.create(\"packageAlreadyPublishedWithDifferentContents\", pkg.uri(), computedChecksum, receivedChecksum)","messagePattern":"ErrorMessages\\.create\\(\"packageAlreadyPublishedWithDifferentContents\", pkg\\.uri\\(\\), computedChecksum, receivedChecksum\\)","errorType":"error_code","errorClass":"PklException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/project/ProjectPackager.java","lineNumber":228,"sourceCode":"              metadataFile,\n              metadataChecksumFile,\n              zipFile,\n              zipChecksumFile,\n              metadataFileChecksum,\n              null,\n              null);\n    }\n    packageResults.put(pkg.uri(), result);\n    return result;\n  }\n\n  private void checkAlreadyPublishedPackage(Package pkg, String computedChecksum)\n      throws IOException {\n    try {\n      var metadataAndChecksum = packageResolver.getDependencyMetadataAndComputeChecksum(pkg.uri());\n      var receivedChecksum = metadataAndChecksum.second.getSha256();\n      if (!receivedChecksum.equals(computedChecksum)) {\n        throw new PklException(\n            ErrorMessages.create(\n                \"packageAlreadyPublishedWithDifferentContents\",\n                pkg.uri(),\n                computedChecksum,\n                receivedChecksum));\n      }\n    } catch (PackageLoadError e) {\n      if (e.getMessageName().equals(\"badHttpStatusCode\")) {\n        var firstArg = e.getArguments()[0];\n        assert firstArg != null;\n        var statusCode = (int) firstArg;\n        if (statusCode == 404) {\n          return;\n        } else {\n          throw new PklException(\n              ErrorMessages.create(\n                  \"unableToAccessPublishedPackage\", pkg.name(), pkg.packageZipUrl(), statusCode));\n        }","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/project/ProjectPackager.java#L210-L246","documentation":"Thrown when packaging a project whose package is already published, but the SHA-256 checksum of the local contents does not match the checksum of the already-published package. Pkl refuses to re-publish because the published artifact would differ from what is already in the registry. This guards against accidental package mutation under the same name/version.","triggerScenarios":"Running `pkl project package` (doPackage) for a package name+version that already exists in the remote registry, after any file inside the package changed since it was first published.","commonSituations":"Editing Pkl files after publishing without bumping the package version; a dirty working tree or generated files differing from the original publish; building on a branch where package contents drifted from the release tag.","solutions":["Bump the package version in PklProject (e.g. 1.0.0 -> 1.0.1) and re-package","Revert the local changes so the package contents exactly match the published version","Verify the computed checksum is not affected by line-ending or build-environment differences and republish deliberately to a new version"],"exampleFix":"// before (PklProject)\npackage { version = \"1.0.0\" }\n// after\npackage { version = \"1.0.1\" }","handlingStrategy":"validation","validationCode":"// shell: compare local checksum with published one before packaging\npkl project package --dry-run 2>&1 || true\ngit status --porcelain   # ensure clean tree before publishing\n# or programmatically: compute sha256 of the built zip and compare with the registry value","typeGuard":null,"tryCatchPattern":"try { packager.package(project) } catch (PklException e) { if (e.message.contains(\"packageAlreadyPublishedWithDifferentContents\")) bumpVersionAndRetry() else throw e }","preventionTips":["Always bump the version in PklProject before re-packaging after edits","Publish only from a clean git tree at a version tag","Avoid generated files with timestamps inside packaged content"],"tags":["packaging","checksum","publishing"],"backgroundTag":"checksum-mismatch","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}