{"record":{"id":"823206c585cbf65e","repo":"apple/pkl","slug":"unabletoaccesspublishedpackage","errorCode":"unableToAccessPublishedPackage","errorMessage":"ErrorMessages.create(\"unableToAccessPublishedPackage\", pkg.name(), pkg.packageZipUrl(), statusCode)","messagePattern":"ErrorMessages\\.create\\(\"unableToAccessPublishedPackage\", pkg\\.name\\(\\), pkg\\.packageZipUrl\\(\\), statusCode\\)","errorType":"error_code","errorClass":"PklException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/project/ProjectPackager.java","lineNumber":243,"sourceCode":"      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        }\n      }\n      throw e;\n    } catch (SecurityManagerException e) {\n      throw new PklException(e.getMessage());\n    }\n  }\n\n  private String createDependencyMetadataAndComputeChecksum(\n      Project project, Package pkg, Path metadataFile, String zipFileChecksum) throws IOException {\n    var dependencyMetadata = createDependencyMetadata(project, pkg, zipFileChecksum);\n    try (var fos = newDigestOutputStream(Files.newOutputStream((metadataFile)))) {\n      dependencyMetadata.writeTo(fos);\n      return ByteArrayUtils.toHex(fos.getMessageDigest().digest());\n    }\n  }","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/project/ProjectPackager.java#L225-L261","documentation":"Thrown when the pre-publish check tries to fetch the already-published package zip from the registry and receives an unexpected HTTP status code (anything other than 200 or 404). It indicates the registry is unreachable, misbehaving, or the package URL is wrong, so Pkl cannot determine whether the package was already published.","triggerScenarios":"During doPackage, the SecurityManager fetch of pkg.packageZipUrl() fails with a non-404 HTTP error status (e.g. 401, 403, 500, 502).","commonSituations":"Corporate proxy or firewall returning 403; registry outage returning 5xx; expired credentials for a private registry; typo'd repository URL in PklProject.","solutions":["Check the reported HTTP status code against the registry: fix authentication (401/403) or retry later if it's a 5xx outage","Verify the `repositoryUrl`/registry configuration in PklProject points to the correct host","Test the package zip URL directly (curl) to confirm what the server returns"],"exampleFix":"// before (PklProject)\npackage { repositoryUrl = \"https://example.wrong/host\" }\n// after\npackage { repositoryUrl = \"https://registry.pkl-lang.org/package-annotation\" }","handlingStrategy":"try-catch","validationCode":"// check the registry is reachable before packaging\ncurl -s -o /dev/null -w '%{http_code}' \"$REPO_URL\" | grep -q '^2' || echo 'registry unreachable'","typeGuard":null,"tryCatchPattern":"try { packager.package(project) } catch (PklException e) { if (e.message.contains(\"unableToAccessPublishedPackage\")) checkRegistryStatus(extractStatusCode(e)) else throw e }","preventionTips":["Test the package zip URL with curl before publishing","Keep registry credentials fresh in CI","Add retry/backoff for 5xx statuses"],"tags":["http","network","publishing"],"backgroundTag":"http-error-response","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}