{"record":{"id":"1817294fc756e6da","repo":"apple/pkl","slug":"nodescendentpathbetweenmodules","errorCode":"noDescendentPathBetweenModules","errorMessage":"noDescendentPathBetweenModules","messagePattern":"noDescendentPathBetweenModules","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/stdlib/base/ModuleClassNodes.java","lineNumber":57,"sourceCode":"        CompilerDirectives.transferToInterpreter();\n        throw exceptionBuilder().evalError(\"expectedModuleAsArgument\").build();\n      }\n      var selfKey = VmUtils.getModuleInfo(self).getModuleKey();\n      var selfUri = selfKey.getUri();\n      var otherKey = VmUtils.getModuleInfo(other).getModuleKey();\n      var otherUri = otherKey.getUri();\n\n      var index = selfUri.toString().lastIndexOf('/');\n      if (index != -1) {\n        var baseUri = URI.create(selfUri.toString().substring(0, index + 1));\n        var relativizedUri = baseUri.relativize(otherUri);\n        if (!relativizedUri.isAbsolute()) {\n          var pathElements = relativizedUri.getPath().split(\"/\");\n          return VmList.create(pathElements, pathElements.length - 1);\n        }\n      }\n\n      throw exceptionBuilder()\n          .evalError(\"noDescendentPathBetweenModules\", selfUri, otherUri)\n          .build();\n    }\n  }\n}\n","sourceCodeStart":39,"sourceCodeEnd":63,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/stdlib/base/ModuleClassNodes.java#L39-L63","documentation":"Thrown by Module.relativePathTo when the two modules are not related by a descendant path: relativizing the other module's URI against the receiver's URI did not yield a relative (hierarchical) path. This happens when the modules live under unrelated URI schemes or disjoint hierarchies, so no meaningful relative path exists.","triggerScenarios":"Calling selfModule.relativePathTo(otherModule) where otherUri cannot be relativized against selfUri — e.g. one module from a project:/ or package resolver scheme and the other from file:, or from sibling unrelated roots where the relativized URI remains absolute.","commonSituations":"Comparing modules fetched from different package/project roots, mixing `file:` modules with `project:`/`package:` dependencies, or calling across modules loaded by different resolvers.","solutions":["Ensure both modules belong to the same project/hierarchy so a relative path exists","Use an absolute URI (otherModule.moduleUri) instead of a relative path when the modules are unrelated","Move the target module into the same project directory tree","Compute the path manually with URI utilities if you must cross hierarchies"],"exampleFix":"// before\nmodule.relativePathTo(externalPackageModule) // unrelated roots\n// after\notherModule.moduleUri // use absolute reference instead","handlingStrategy":"validation","validationCode":"function sameHierarchy(a: Module, b: Module): Boolean =\n  a.moduleUri.startsWith(commonPrefix) && b.moduleUri.startsWith(commonPrefix)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use relativePathTo between modules in the same project/package hierarchy","Fall back to absolute moduleUri when modules come from different resolvers","Avoid mixing file: and package:/project: module schemes for path computation"],"tags":["pkl","module","uri","stdlib"],"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-14T16:17:12.679Z"}