Skip to content

Centralize native value conversion - #1011

Merged
snazy merged 5 commits into
projectnessie:mainfrom
snazy:centr-nat-val-conv
Oct 22, 2026
Merged

snazy merged 5 commits into
projectnessie:mainfrom
snazy:centr-nat-val-conv

Conversation

@snazy

@snazy snazy commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Make TypeAdapter the bidirectional boundary for Java/CEL conversion, with primitive conversion helpers and shared default implementations. Retain deprecated Val.convertToNative() as the compatibility fallback for custom values.

Route list and map exports through the calling adapter, including nested containers and protobuf-backed maps. Preserve CEL values during list concatenation so outbound conversion hooks cannot alter evaluation results.

Preserve primitive range checks and boxed conversion targets for custom protobuf map entries. Correct unsigned protobuf map reads and reject out-of-range uint32 and fixed32 keys and values before narrowing (see #985).

Add regression coverage for custom adapters, legacy conversions, nested containers, concatenation, and generated/dynamic protobuf round trips, plus conversion benchmarks.

@snazy
snazy force-pushed the centr-nat-val-conv branch from ad881ae to af540d3 Compare October 16, 2026 16:50
@snazy
snazy requested a review from XN137 October 16, 2026 16:50
@snazy
snazy marked this pull request as ready for review October 16, 2026 16:50
@snazy
snazy marked this pull request as draft October 16, 2026 17:20
Make TypeAdapter the bidirectional conversion boundary while retaining the deprecated Val conversion fallback. Preserve scalar ranges, configured container adapters, and protobuf built-in and object type values; validate uint32 map entries before narrowing.
@snazy
snazy force-pushed the centr-nat-val-conv branch from af540d3 to e34eea7 Compare October 16, 2026 18:09
@snazy
snazy marked this pull request as ready for review October 16, 2026 18:13
@snazy
snazy force-pushed the centr-nat-val-conv branch from e34eea7 to adb1862 Compare October 16, 2026 19:20
Comment thread core/src/main/java/org/projectnessie/cel/common/types/MapT.java Outdated
snazy added 2 commits October 21, 2026 19:31
Route native map keys and values through the configured adapter while preserving raw value access. Normalize uint32 and fixed32 map entries without sign extension, retaining output range validation.

Add regression coverage for nested conversions, null and type values, generated and dynamic unsigned maps, and out-of-range keys and values.

@XN137 XN137 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.

thanks for the update, 2 more legit-looking findings

Comment thread core/src/main/java/org/projectnessie/cel/common/types/ListT.java
Comment thread core/src/main/java/org/projectnessie/cel/common/types/pb/ProtoTypeRegistry.java Outdated
Use the calling adapter when converting built-in list elements, including string arrays and split results. Preserve legacy string-array element adaptation and custom list conversions.

Preserve boxed conversion targets for custom protobuf map entries while retaining built-in primitive fast paths. Cover Java and protobuf list outputs, split overloads, null string-array elements, and boxed-only map keys and values.
@snazy

snazy commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

thanks for the update, 2 more legit-looking findings

Yup, addressed

Comment thread core/src/main/java/org/projectnessie/cel/common/types/ListT.java Outdated
Pass the calling adapter through built-in map conversion, including protobuf-backed maps and nested Java and protobuf output. Preserve custom map legacy conversion and raw value access.

Retain CEL elements when concatenating array-backed and Java-backed lists so outbound hooks cannot alter evaluation or narrow element types. Preserve unsigned raw representations in concatenation snapshots. Cover delegated inbound adapters, nested map exports, protobuf maps, and typed-array concatenation.
@snazy
snazy requested a review from XN137 October 22, 2026 09:39

@XN137 XN137 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.

no more codex findings

maybe adjust the PR description to also include something like:

  • Normalizing incoming uint32/fixed32 map entries without sign extension, so valid unsigned values still round-trip with the new range checks.
  • Preserving CEL values during list concatenation, so outbound adapter hooks cannot change evaluation results or narrow element types.

@snazy
snazy merged commit 4d4d247 into projectnessie:main Oct 22, 2026
3 checks passed
@snazy
snazy deleted the centr-nat-val-conv branch October 22, 2026 11:50
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.

2 participants