{"record":{"id":"cf13f047ba1132d7","repo":"apple/pkl","slug":"errormessages-create","errorCode":null,"errorMessage":"ErrorMessages.create(\"\")","messagePattern":"ErrorMessages\\.create\\(\"\"\\)","errorType":"error_code","errorClass":"URISyntaxException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/project/CanonicalPackageUri.java","lineNumber":65,"sourceCode":"              null,\n              null);\n    } catch (URISyntaxException e) {\n      throw PklBugException.unreachableCode();\n    }\n    return new CanonicalPackageUri(baseUri, packageUri.getVersion().getMajor());\n  }\n\n  public static CanonicalPackageUri of(String uriStr) throws URISyntaxException {\n    var versionIdx = uriStr.lastIndexOf('@');\n    if (versionIdx == -1) {\n      throw new URISyntaxException(\n          uriStr, ErrorMessages.create(\"missingVersionInPackageUri\", uriStr));\n    }\n    int majorVersion;\n    try {\n      majorVersion = Integer.parseInt(uriStr.substring(versionIdx + 1));\n    } catch (NumberFormatException e) {\n      throw new URISyntaxException(uriStr, ErrorMessages.create(\"\"));\n    }\n    var baseUri = new URI(uriStr.substring(0, versionIdx));\n    return new CanonicalPackageUri(baseUri, majorVersion);\n  }\n\n  /**\n   * @deprecated As of 0.28.0, replaced by {@link #majorVersion()}.\n   */\n  @Deprecated(forRemoval = true)\n  public int getMajorVersion() {\n    return majorVersion;\n  }\n\n  /**\n   * @deprecated As of 0.28.0, replaced by {@link #baseUri()}.\n   */\n  @Deprecated(forRemoval = true)\n  public URI getBaseUri() {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/project/CanonicalPackageUri.java#L47-L83","documentation":"CanonicalPackageUri.of() parses a canonical package URI of the form baseUri@majorVersion. If the text after '@' cannot be parsed as an integer (the major version), a URISyntaxException with an EMPTY message is thrown. The empty message is a bug/oversight — it gives the caller no clue about what failed.","triggerScenarios":"Calling CanonicalPackageUri.of(uriStr) with a URI whose suffix after '@' is non-numeric or empty, e.g. 'package://example.com/foo@' or 'package://example.com/foo@abc'.","commonSituations":"Hand-typed package URIs in PklProject files or CLI arguments; copying URIs with a trailing '@'; programmatic URI construction concatenating base URI and version where the version variable is empty or malformed.","solutions":["Fix the URI so the part after '@' is a plain integer major version (e.g. package://example.com/foo@1)","Check that the '@' separator is present and the string after it is not empty","If constructing programmatically, validate the version with Integer.parseInt before building the URI","Report/patch the empty ErrorMessages.create(\"\") to include the URI and expected format"],"exampleFix":"// before\nString uri = \"package://example.com/my.pkg@\";\n// after\nString uri = \"package://example.com/my.pkg@1\";","handlingStrategy":"validation","validationCode":"int at = uri.indexOf('@');\nif (at < 0 || !uri.substring(at + 1).matches(\"\\\\d+\")) throw new IllegalArgumentException(\"package URI must end in @<majorVersion>: \" + uri);","typeGuard":"boolean isValidPackageUri(String uri) { int at = uri.lastIndexOf('@'); return at > 0 && uri.substring(at + 1).matches(\"\\\\d+\"); }","tryCatchPattern":"try { return CanonicalPackageUri.of(uri); } catch (URISyntaxException e) { throw new IllegalArgumentException(\"invalid package URI (expected base@majorVersion): \" + uri, e); }","preventionTips":["Always build package URIs from validated integer versions","Add a pre-parse regex check for base@majorVersion format","Never hand-write package URIs; use tooling to generate them"],"tags":["uri","parsing","package-uri"],"backgroundTag":"invalid-url-format","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"}