fix(core): clean up Effect audit patterns (#35174)

This commit is contained in:
Kit Langton 2026-07-03 13:54:13 -04:00 committed by GitHub
commit 1b88ff8d53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 118 additions and 62 deletions

View file

@ -35,6 +35,7 @@ const RawMatch = Schema.Struct({
),
}),
})
const decodeJsonRecord = Schema.decodeUnknownEffect(Schema.UnknownFromJsonString)
type RawMatchData = (typeof RawMatch.Type)["data"]
@ -232,10 +233,7 @@ const layer = Layer.effect(
parse: (line) =>
(Buffer.byteLength(line, "utf8") > MAX_RECORD_BYTES
? Effect.fail(failure(`Ripgrep JSON record exceeded ${MAX_RECORD_BYTES} bytes`))
: Effect.try({
try: () => JSON.parse(line) as unknown,
catch: (cause) => failure("Invalid ripgrep JSON output", cause),
})
: decodeJsonRecord(line).pipe(Effect.mapError((cause) => failure("Invalid ripgrep JSON output", cause)))
).pipe(
Effect.flatMap((json) => {
if (!json || typeof json !== "object" || !("type" in json) || json.type !== "match")