Skip to content

fix(compiler): preserve prototype-named keys during camelCase conversion - #89

Merged
setu4993 merged 1 commit into
salesforce:mainfrom
BichengWang:BichengWang/contribution-prototype-record-20261008
Oct 9, 2026
Merged

setu4993 merged 1 commit into
salesforce:mainfrom
BichengWang:BichengWang/contribution-prototype-record-20261008

Conversation

@BichengWang

@BichengWang BichengWang commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What

Preserve arbitrary record keys named constructor, toString, hasOwnProperty, or __proto__ during schema-guided camelCase conversion. Keep declared-field conversion and source ranges intact, with ordinary output-object prototypes and data properties.

Why

The schema-shape dictionary inherited Object.prototype, so an object-valued record entry such as configuration.constructor = { customer_name: 'Ada' } was mistaken for a declared Zod schema and crashed. An own __proto__ key is also misclassified, causing a crash or incorrect renaming. Preserving that key additionally requires defining an own data property so the output object's legacy prototype setter is not invoked.

Fixes #88.

How

Use a prototype-free dictionary for accumulated schema fields and define output entries as enumerable, writable, configurable data properties. Add 21 real-Zod regression cases using the generated byoClientConfig schema and declared object/record schemas, covering values, prototypes, input preservation, and exact range remapping. No generated schemas or dependencies changed.

Test Plan

The final regression tests produce 18 failures on the original converter and pass all 21 cases with the fix. These are local results; upstream CI results are not claimed here.

  • Existing tests pass (pnpm test), including 912 compiler and 309 Agentforce tests; existing skips remain
  • New/updated tests cover the change
  • Linting and type checks pass (pnpm lint && pnpm typecheck); lint reports 12 warnings in unchanged UI files, and changed-file ESLint has none
  • Repository formatting passes (pnpm format:check)
  • Existing Agentforce camelCase suite passes (5 tests)

Checklist

  • Code follows the project's coding style (formatting and changed-file ESLint pass)
  • Diff inspected; no blocking implementation findings
  • Documentation updated as needed (implementation comments; no public API change)
  • This change does not introduce new warnings

@setu4993 setu4993 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is great. Thank you, Kenneth!

@setu4993
setu4993 enabled auto-merge (squash) October 9, 2026 16:34
@setu4993
setu4993 disabled auto-merge October 9, 2026 16:35
@setu4993
setu4993 merged commit 7d48eaa into salesforce:main Oct 9, 2026
8 checks passed
@BichengWang
BichengWang deleted the BichengWang/contribution-prototype-record-20261008 branch October 9, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] camelCase conversion crashes on prototype-named record keys

2 participants