{"record":{"id":"9d3df628745cc723","repo":"apple/pkl","slug":"i-o-error-reading-path-touri","errorCode":null,"errorMessage":"I/O error reading `${path.toUri()}`.","messagePattern":"I/O error reading `(.+?)`\\.","errorType":"exception","errorClass":"DocGeneratorBugException","httpStatus":null,"severity":"error","filePath":"pkl-doc/src/main/kotlin/org/pkl/doc/PackageDataGenerator.kt","lineNumber":249,"sourceCode":"\n  /** The source code pattern, with placeholders (e.g. `%{path}`) */\n  val sourceCodeUrlScheme: String?,\n\n  /** The dependencies of this package. */\n  val dependencies: List<DependencyData> = listOf(),\n\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,","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-doc/src/main/kotlin/org/pkl/doc/PackageDataGenerator.kt#L231-L267","documentation":"PackageDataGenerator.read loads serialized PackageData from a JSON file on disk and wraps any IOException from reading that file into a DocGeneratorBugException with this message. It indicates the package data file could not be read (missing, unreadable, or an I/O failure), with the original IOException attached as cause.","triggerScenarios":"Calling PackageDataGenerator.read(path) where path.readString() throws IOException — file does not exist, no read permission, path is a directory, or a transient I/O error occurs.","commonSituations":"Running migration/regeneration on an incomplete output directory; files deleted by a clean task mid-run; wrong outputDir configured so the expected data file path doesn't exist.","solutions":["Check the wrapped IOException cause for the exact path and reason","Verify the package data file exists at the given path and is readable","Regenerate or restore the missing package data file before reading"],"exampleFix":"// before\nval data = PackageDataGenerator.read(dataPath) // throws if file missing\n// after\nif (dataPath.exists()) {\n  val data = PackageDataGenerator.read(dataPath)\n} else {\n  regeneratePackageData(dataPath)\n}","handlingStrategy":"try-catch","validationCode":"require(dataPath.isRegularFile() && dataPath.isReadable()) { \"Package data file missing or unreadable: $dataPath\" }","typeGuard":null,"tryCatchPattern":"try { val data = PackageDataGenerator.read(path) } catch (e: DocGeneratorBugException) { val io = e.cause as? IOException ?: throw e; logger.error(\"read failed\", io) }","preventionTips":["Verify the expected data file exists before reading (read-and-rewrite flows)","Regenerate missing data files instead of failing hard","Check outputDir configuration points at the right tree"],"tags":["io","file-read","wrapped-exception"],"backgroundTag":"file-read-failed","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"}