Skip to content

improvement(utils): adopt toRecord and toRecordOrNull over inline record coercions - #8053

Merged
waleedlatif1 merged 2 commits into
stagingfrom
consolidate/round-2
Sep 20, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
consolidate/round-2

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • @sim/utils/object already exported toRecord(v) (isRecordLike(v) ? v : {}) and toRecordOrNull(v) (… : null). This adopts them at the 117 inline sites that spelled those shapes out by hand
  • Deletes 13 named local duplicates of the same two helpers (asRecord, record, objectValue, asObject) across harmonic, quickbooks, sim-setup, onepassword ×2, cbinsights, instantly, bitbucket ×2, google-drive, jira, slack and the slack-custom-ingress inline copy, repointing their importers
  • Domain-named wrappers with many callers (confluence asObject, google-drive asObject, jira asObject, slack record) keep their names and delegate their bodies, matching the microsoft-teams client that already did this
  • Adds no new helper and changes no behavior: every replaced body was semantically identical, and each deleted wrapper's return alias resolves to Record<string, unknown>

Deliberately left alone: 5 sites of the form isRecordLike(data) ? data.prop : null, where the tested and returned expressions differ — toRecord(data).prop would yield undefined rather than null. Also out of scope, and a candidate for a follow-up: ~33 negated guard prologues (if (!v || typeof v !== 'object' || Array.isArray(v)) return null) that each carry an as Record<string, unknown> cast the helper would remove.

Type of Change

  • Refactor / improvement

Testing

  • bun run type-check clean in apps/sim, apps/desktop, apps/realtime, packages/{utils,emcn,sim-cli,sim-setup}
  • Targeted vitest across every touched area: 8,492 in apps/sim, 1,657 desktop, 1,165 sim-cli, 408 realtime, 247 utils, 170 sim-setup
  • bun run lint, check:audits (47/47), test:scripts (351), block-registry check and docs-manifest:check all pass
  • Reviewed for semantic equivalence site by site, including double-evaluation (no replaced expression was a call), optional-chaining behavior, and lost type narrowing

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

🤖 Generated with Claude Code

…gh toRecord

The first pass matched one operand order, so six exact equivalents written
`x !== null && typeof x === 'object'` survived — two of them beside a sibling
the pass had already deleted. Domain-named wrappers keep their names and
delegate, matching the microsoft-teams client that already did.
@vercel

vercel Bot commented Sep 20, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
docs Ready Ready Preview Sep 20, 2026 1:57am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge because the new helper calls preserve the predicates, return identities, and fallback values of the replaced coercions.

Summary

This PR centralizes object-to-record coercion by replacing equivalent inline checks and local wrappers with toRecord and toRecordOrNull.

  • Preserves existing fallback and identity behavior across workflow execution, webhook handling, provider integrations, desktop IPC, and setup tooling.
  • Removes redundant local coercion helpers and updates their callers.
  • No behavioral, security, or repository-rule violations were identified.

Reviews (1) · Last reviewed commit: "improvement(utils): route the remaining ..."

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 102 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 4dd929a into staging Sep 20, 2026
37 checks passed
@waleedlatif1
waleedlatif1 deleted the consolidate/round-2 branch September 20, 2026 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant