Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: base64-encode bloop error ids #5920

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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