Skip to content

fix(rees): TypeError in safeCodeSpan -- non-string value reaches .replace() (13 Sentry events) #5002

Description

@JSONbored

Summary

TypeError: value.replace is not a function in the REES enrichment service's Markdown rendering — a non-string value reaches a helper typed to accept only string.

Evidence (Sentry)

GITTENSORY-15 — 13 events, first seen 2026-07-02, last seen 2026-07-05. Full stack trace:

src/render-helpers.ts:29 (safeCodeSpan)
  return `\`${value.replace(CODE_SPAN_UNSAFE, (char) => CODE_SPAN_REPLACEMENTS[char] ?? "�")}\`";
src/analyzers/registry.ts:824 (ANALYZER_DESCRIPTORS.render)
  ...${helpers.safeCodeSpan(`${item.file}:${item.line}`)} — ${helpers.safeCodeSpan(item.term)} → ${helpers.safeCodeSpan(item.suggestion)}
src/render.ts:20 (renderDescriptorSection)
src/render.ts:479 (renderBrief)
src/brief.ts:429 (buildBrief)
src/server.ts:77

Request: POST https://enrichment.gittensory.aethereal.dev/v1/enrich.

Root cause — verify from the stack trace, not from Seer

Seer's summary for this issue ("Increase the transport headroom constant so analyzers stop early enough for the response to reach the client before its abort fires") is about a timeout/transport issue and does not match this stack trace at all, which is a plain TypeError from a .replace() call. Ignore Seer's summary for this issue; the stack trace is unambiguous.

At registry.ts:824, three safeCodeSpan(...) calls are made: one on a template-literal-interpolated string (${item.file}:${item.line}, already coerced to a string), and two on raw values (item.term, item.suggestion) with no coercion. If either of those is undefined, null, a number, or an array for some analyzer's finding shape, safeCodeSpan's .replace() call throws.

Requirements

  1. Either make safeCodeSpan defensive (accept unknown, coerce via String(value) or similar, matching the codebase's usual defensive-formatting conventions) or ensure every call site only ever passes a genuine string — pick whichever matches this file's existing house style for similar helpers.
  2. Identify which analyzer/finding shape can produce a non-string term or suggestion and whether that's itself a data-shape bug worth separately noting (even if not fixing).

Deliverables

  • Code fix + regression test (a non-string term/suggestion value exercised through safeCodeSpan).

Metadata

Metadata

Assignees

Labels

maintainer-onlyOwner-only work — yields no Gittensor points.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions