Skip to content

Add Conjure compliant deserialization engine#197

Draft
afloren-palantir wants to merge 1 commit into
developfrom
afloren/null-safe-deserialization-engine
Draft

Add Conjure compliant deserialization engine#197
afloren-palantir wants to merge 1 commit into
developfrom
afloren/null-safe-deserialization-engine

Conversation

@afloren-palantir

@afloren-palantir afloren-palantir commented Jun 30, 2026

Copy link
Copy Markdown

Summary

Adds a schema-driven deserialization engine to conjure-client implementing the Conjure wire spec §5.6, motivated by and addressing palantir/conjure-typescript#48, #78, #156.

New exports from conjure-client

  • ConjureType — discriminated union type descriptor + builder functions (string(), list(item), object(fields), union(variants), etc.)
  • deserialize<T>(type, json) — applies §5.6 coercions recursively
  • ConjureDeserializeError — thrown on violations, carries the dot/bracket JSON path to the failing field

§5.6 behaviours implemented

  • optional null/absent → undefined (addresses Excavator: Update policy-bot config #156: standardise on undefined not null)
  • list/set/map null → empty collection (addresses Excavator: Upgrade dependencies #78: null collections from server)
  • Required field null/absent → ConjureDeserializeError
  • integer — validates 32-bit signed range and integrality (§5.1)
  • safelong — validates Number.isSafeInteger() range ±(2^53−1) (§5.1)
  • double — converts "NaN"/"Infinity"/"-Infinity" wire strings to actual JS number values (addresses Update dev dependencies #48: ergonomic double handling)
  • boolean — rejects "true" string, no implicit cast (§5.6.2)
  • union unknown variant → pass through unchanged (§4.4 forward-compat)
  • enum unknown value → pass through as string (§4.1 forward-compat)
  • Unknown object fields → ignored (§4.1 forward-compat)

Design

The engine is schema-driven: callers supply a ConjureType descriptor built from the builder functions. The companion PR (palantir/conjure-typescript#396) generates _TypeName descriptor constants for every type and wires them into service calls automatically when --useDeserializer is set. Flag is opt-in and default-off — no impact on existing code.

Test plan

  • yarn test passes in packages/conjure-client
  • Verify deserialize and ConjureType builders are re-exported from the package root

🤖 Generated with Claude Code

@changelog-app

changelog-app Bot commented Jun 30, 2026

Copy link
Copy Markdown

Generate changelog in packages/conjure-client/changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Add Conjure compliant deserialization engine

Check the box to generate changelog(s)

  • Generate changelog entry

Introduces a schema-driven `deserialize<T>(type, json)` function and
`ConjureType` descriptor DSL to conjure-client, addressing the serde
layer requested in palantir/conjure-typescript#48, #78, #156.

Key behaviours (Conjure wire spec §5.6):
- null/absent optional → undefined
- null/absent list/set/map → empty collection/object
- integer: validates 32-bit signed range (§5.1)
- safelong: validates ±(2^53−1) safe-integer range (§5.1)
- double: converts "NaN"/"Infinity"/"-Infinity" wire strings to JS numbers (§5.1)
- No implicit type casting (§5.6.2: "true" is not boolean)
- Unknown union variants pass through unchanged (§4.4 forward-compat)
- Unknown object fields ignored (§4.1 forward-compat)
- Unknown enum values tolerated (§4.3 forward-compat)

Builder functions: stringType, booleanType, integer, safelong, double,
rid, uuid, bearertoken, binary, datetime, anyType, enumType, optional,
list, set, map, object, union, alias, reference (lazy thunk for recursion).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@afloren-palantir afloren-palantir force-pushed the afloren/null-safe-deserialization-engine branch from eab80d2 to b78bae2 Compare June 30, 2026 20:07
@afloren-palantir afloren-palantir changed the title Add Conjure §5.6.1 null-safe deserialization engine Add Conjure compliant deserialization engine Jun 30, 2026
@changelog-app

changelog-app Bot commented Jun 30, 2026

Copy link
Copy Markdown

Successfully generated changelog entry!

Need to regenerate?

Simply interact with the changelog bot comment again to regenerate these entries.


📋Changelog Preview

✨ Features

  • Add Conjure compliant deserialization engine (#197)

@afloren-palantir afloren-palantir marked this pull request as draft June 30, 2026 21:38
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