Skip to content

Commit

Permalink
improvement: base64-encode bloop error ids
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek authored and tgodzik committed Dec 7, 2023
1 parent 1170441 commit 1b012d5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import scala.meta.internal.metals.Report
import scala.meta.internal.metals.ReportContext
import scala.meta.internal.metals.Tables

import com.google.common.io.BaseEncoding

class BspErrorHandler(
currentSession: () => Option[BspSession],
tables: Tables,
Expand All @@ -30,11 +32,8 @@ class BspErrorHandler(
protected def logError(message: String): Unit = scribe.error(message)

private def createReport(message: String) = {
val id = MessageDigest
.getInstance("MD5")
.digest(message.getBytes)
.map(_.toChar)
.mkString
val digest = MessageDigest.getInstance("MD5").digest(message.getBytes)
val id = BaseEncoding.base64().encode(digest)
val sanitized = reportContext.bloop.sanitize(message)
reportContext.bloop.create(
Report(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ object Report {
def apply(name: String, text: String, error: Throwable): Report =
Report(name, text, error, path = None)

val idPrefix = "id: "
val idPrefix = "error id: "
val summaryTitle = "#### Short summary: "
}

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/src/test/scala/tests/ReportsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class ReportsSuite extends BaseSuite {
val obtained =
new String(Files.readAllBytes(path.get), StandardCharsets.UTF_8)
assertNoDiff(
s"""|id: $testId
s"""|error id: $testId
|${exampleText(StdReportContext.WORKSPACE_STR)}
|#### Short summary:
|
Expand Down

0 comments on commit 1b012d5

Please sign in to comment.