{"record":{"id":"9c2c710ae96906a6","repo":"apple/pkl","slug":"error-deserializing-path-touri","errorCode":null,"errorMessage":"Error deserializing `${path.toUri()}`.","messagePattern":"Error deserializing `(.+?)`\\.","errorType":"exception","errorClass":"DocGeneratorBugException","httpStatus":null,"severity":"error","filePath":"pkl-doc/src/main/kotlin/org/pkl/doc/PackageDataGenerator.kt","lineNumber":255,"sourceCode":"\n  /** The modules in this package. */\n  val modules: List<ModuleData> = listOf(),\n) {\n  companion object {\n    val json = Json { serializersModule = serializers }\n\n    fun read(path: Path): PackageData {\n      val jsonStr: String =\n        try {\n          path.readString()\n        } catch (e: IOException) {\n          throw DocGeneratorBugException(\"I/O error reading `${path.toUri()}`.\", e)\n        }\n\n      return try {\n        json.decodeFromString(jsonStr)\n      } catch (e: SerializationException) {\n        throw DocGeneratorBugException(\"Error deserializing `${path.toUri()}`.\", e)\n      }\n    }\n  }\n\n  constructor(\n    pkg: DocPackage\n  ) : this(\n    PackageRef(pkg.name, pkg.uri, pkg.version),\n    getDocCommentSummary(pkg.overview),\n    pkg.docPackageInfo.annotations.deprecation,\n    pkg.docPackageInfo.sourceCode,\n    pkg.docPackageInfo.sourceCodeUrlScheme,\n    pkg.docPackageInfo.dependencies.map { DependencyData(PackageRef(it.name, it.uri, it.version)) },\n    pkg.docModules.mapNotNull { if (it.isUnlisted) null else ModuleData(pkg, it) },\n  )\n\n  fun write(path: Path) {\n    val jsonStr =","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-doc/src/main/kotlin/org/pkl/doc/PackageDataGenerator.kt#L237-L273","documentation":"PackageDataGenerator.read parses the file contents as JSON into a PackageData object; if kotlinx.serialization throws a SerializationException, it is wrapped in a DocGeneratorBugException with this message. The file was readable but its contents are not valid PackageData JSON, so deserialization failed.","triggerScenarios":"Calling PackageDataGenerator.read(path) on a file whose JSON does not match the PackageData schema — malformed JSON, wrong fields/types, or output from an incompatible pkl-doc version.","commonSituations":"Hand-edited package data files; truncated writes from a previous crashed run; reading a data file produced by a different pkl-doc version with a changed schema.","solutions":["Regenerate the package data file from source rather than repairing it by hand","Validate the file is well-formed JSON matching the PackageData schema","Check the wrapped SerializationException for the exact field/path that failed"],"exampleFix":"// before\nval data = PackageDataGenerator.read(corruptPath) // DocGeneratorBugException\n// after\nregeneratePackageData(corruptPath) // rewrite file from source\nval data = PackageDataGenerator.read(corruptPath)","handlingStrategy":"try-catch","validationCode":"val json = Json { ignoreUnknownKeys = true }\ntry { json.parseToJsonElement(dataPath.readText()) } catch (e: Exception) { regeneratePackageData(dataPath) }","typeGuard":null,"tryCatchPattern":"try { val data = PackageDataGenerator.read(path) } catch (e: DocGeneratorBugException) { if (e.cause is SerializationException) { regeneratePackageData(path) } else throw e }","preventionTips":["Never hand-edit serialized package data files","Regenerate data after upgrading pkl-doc versions","Guard against truncated writes by regenerating on parse failure"],"tags":["json","deserialization","corrupt-data"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}