Skip to content

finding(app-shell): the __proto__ instrument assertion in MetadataService.objectPayloadFieldsMap.test.ts measures {} — the object literal sets the prototype instead of adding a key #6524

Description

@os-support-ai

Found while porting that file's pin pattern to MetadataFieldsPage for objectui#6489 (PR #6520). The claim the assertion makes is true — this is a phantom-check finding, not a correctness one.

The line

packages/app-shell/src/services/MetadataService.objectPayloadFieldsMap.test.ts:155, in describe('the instrument'):

it('keys the record with a snake_case rule — `__proto__` is a LEGAL field name',()=>{// Which is why `toFieldsMap` builds through `Object.fromEntries`: plain// assignment would invoke the prototype setter and drop the field silently.expect(ObjectSchema.safeParse({name: 'account',label: 'Account',fields: {__proto__: {type: 'text',label: 'P'}}}).success).toBe(true);

Why it does not measure what it says

{ __proto__: value } inside an object literal is the Annex B.3.1 prototype-setter syntax: it sets the object's [[Prototype]] and creates no key. Measured:

plain-literal own keys: []
safeParse of the plain literal: success = true
safeParse of an EMPTY fields map (the same input,
honestly spelled — `fields: {}`): success = true

So the assertion parses fields: {} with an unusual prototype and asserts that an empty field map is legal. It is green today, it would stay green if ObjectSchema started refusing __proto__ by name tomorrow, and its failure would say nothing about the key rule.

Same shape as the i18n \w finding (objectui#3866): an assertion that is permanently true for a reason unrelated to its subject — worse than a missing test, because the file reads as if the fact is pinned.

The claim itself holds

Verified independently with a computed key, which defines an own property:

ObjectSchema.safeParse({ …, fields: { ['__proto__']: { type: 'text', label: 'P' } } }) => success = true

So __proto__ really is a spec-legal field name, and toFieldsMap's use of Object.fromEntries really is load-bearing.

Not the whole file

The two __proto__ assertions on captured request bytes (lines 361–362) are honest: JSON.parse defines an own __proto__ property rather than invoking the setter, so Object.keys(fieldsOf(puts)) reads the key back correctly. Only the instrument line is phantom. The sibling file MetadataFieldsPage.fieldsMapKeying.test.tsx (PR #6520) spells every fixture ['__proto__'] and pins the literal-vs-computed distinction itself, so the two files can be read side by side.

Suggested fix

One character class of change — ['__proto__'] — plus a comment saying why, and ideally the same expect(Object.keys({ __proto__: … })).toEqual([]) control that keeps the next author from writing it the plain way again.

Refs: objectui#6240 (the pin's own card) · objectui#6489 / PR #6520 (the port that surfaced this) · objectui#5761 (the parity family)


Generated by Claude Code

Metadata

Metadata

Assignees

Labels

domain:uiobjectui ui stream: fix lands on the published library or apps — objectui execution seatpackage: app-shellpm:dispatchedtests

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions