Skip to content

ref: Remove isRecord and ban Record type guards - #3796

Merged
BYK merged 6 commits into
mainfrom
ref/remove-is-record
Nov 20, 2026
Merged

BYK merged 6 commits into
mainfrom
ref/remove-is-record

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

isRecord only proves that a value is some object. The code after it then reads loose fields by hand. This removes every isRecord helper and adds a lint rule so none comes back.

What changed

  • Helpers removed: the shared one in packages/junior/src/chat/coerce.ts, the copy in packages/junior-github/src/credential-support.ts (with its JsonRecord type), and the local copies in the core, GitHub plugin, and dashboard files.
  • Call sites: unknown data at a boundary (stored state, JSON, webhook and API responses, tool results, guardian markers) is now parsed with zod safeParse. Each site keeps its old fallback. The lenient coercers use per-field .catch() or .optional(), so a bad field is still dropped instead of failing the whole value. Other sites use plain narrowing (typeof, in, Array.isArray, discriminants). No as assertions are added, and the type-assertion baseline goes down for mcp/auth-store.ts, mcp/service-account.ts, plugins/agent-hooks.ts, and state/conversation.ts.
  • Lint rule: junior/no-record-type-guard reports any function or variable named isRecord, and any type guard that narrows to Record<string, unknown> or Record<string, any>. It is on in the root and dashboard oxlint configs. The Record<string, unknown> guards in configuration/defaults.ts and conversation-privacy.ts are also replaced.

Edge cases that now behave differently

  • An array where an object is expected is now rejected in a few places that used the core helper, which counted arrays as objects: the stored credentials root and configuration in mcp/auth-store.ts, and byFileId in slack/vision-cache.ts.
  • z.number() rejects NaN and Infinity in the MCP credential and service-account parsers. The old typeof checks accepted them.
  • Some parsed objects now carry optional keys as undefined instead of leaving them out.

via @BYK.

--

View Session [Sentry]

sentry-junior Bot and others added 4 commits November 19, 2026 15:40
Remove the last isRecord helper and add junior/no-record-type-guard. It
reports any function named isRecord and any type guard that narrows to
Record<string, unknown> or Record<string, any>.

Co-Authored-By: BYK <[email protected]>
@vercel

vercel Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 20, 2026 9:13pm UTC

Request Review

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

13 screenshot changes — 13 changed · 0 added · 0 removed

Review screenshots in Frameshift

Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automation Skill Editor · Desktop
Automation Skill Editor · Desktop
Changed
Automation Skill Editor · Mobile
Automation Skill Editor · Mobile
Changed
Automations Runs Filters · Desktop
Automations Runs Filters · Desktop
Changed
Conversation Attached Linked Work Denied · Desktop
Conversation Attached Linked Work Denied · Desktop
Changed
Conversation Attached Linked Work Denied Light · Desktop
Conversation Attached Linked Work Denied Light · Desktop
Changed
Show 7 more changed screenshots
Conversation Question · Desktop
Conversation Question · Desktop
Changed
Conversation Question Light · Desktop
Conversation Question Light · Desktop
Changed
Conversation Question Picks And Text · Desktop
Conversation Question Picks And Text · Desktop
Changed
Conversation Question Stepper · Desktop
Conversation Question Stepper · Desktop
Changed
Conversation Share Details · Desktop
Conversation Share Details · Desktop
Changed
Inbox Palette Pages · Desktop
Inbox Palette Pages · Desktop
Changed
System Cache Share · Desktop
System Cache Share · Desktop
Changed

@BYK
BYK marked this pull request as ready for review November 19, 2026 22:35
@sentry-junior
sentry-junior Bot requested a review from BYK November 19, 2026 22:35
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 19, 2026
@BYK
BYK enabled auto-merge (squash) November 19, 2026 22:36
Co-Authored-By: Burak Yigit Kaya <[email protected]>

# Conflicts:
#	tools/oxlint/junior/index.ts
@blacksmith-sh

blacksmith-sh Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Found 2 test failures on Blacksmith runners:

Failures

Test View Logs
[classic] › packages/junior-dashboard/e2e/
person-cards.spec.ts:154:1 › a person card says when its activity fails to load
View Logs
packages/junior-dashboard/e2e/person-cards.spec.ts/
a person card says when its activity fails to load
View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@BYK
BYK merged commit 658f224 into main Nov 20, 2026
77 of 79 checks passed
@BYK
BYK deleted the ref/remove-is-record branch November 20, 2026 21:29

This branch was successfully deployed

1 active deployment
Preview – junior-docs — c88ed4a9 Deployed Nov 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant