Repository navigation
series/3.x Set[Byte] under 2.x byte compatibility keeps its elements and reads 2.x data - #1168
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
A critical Scala 2.13 compilation error in the shared interpreter prevents the cross-built project from compiling and blocks verification of the new checks.
1 open issue
What changed in this PR
Adds schema compatibility for Set[Byte], supporting migration between the 2.x list-of-single-byte-binary representation and the 3.x NumberSet representation while preserving empty sets. It also validates set update operations against the field codec.
Changes:
- Adds compatibility-aware encoding and decoding for
Set[Byte]across schema compatibility modes. - Validates
addSetanddeleteFromSetbefore generating update requests when the codec does not produce a native DynamoDB set. - Adds unit, integration, and documentation coverage for legacy and modern wire formats.
| File | Description |
|---|---|
| it/src/test/scala/zio/dynamodb/ByteSetCompatibilitySpec.scala | Verifies Set[Byte] compatibility round trips and stored wire formats against DynamoDB Local. |
| docs/reference/codec.md | Documents the Set[Byte] representations and schema compatibility mappings. |
| blocks-schema/src/test/scala/zio/dynamodb/blocks/schema/DynamoDBCodecDeriverSpec.scala | Tests Set[Byte] encoding and decoding across compatibility modes, including empty sets and malformed legacy elements. |
| blocks-schema/src/main/scala/zio/dynamodb/blocks/schema/DynamoDBCodecDeriver.scala | Implements compatibility-aware codecs for legacy and modern Set[Byte] representations. |
| blocks-schema-ddbexpr/src/test/scala/zio/dynamodb/DdbExprNumericFieldsSpec.scala | Tests set-update validation and containsElement behavior for legacy list encoding. |
| blocks-schema-ddbexpr/src/main/scala/zio/dynamodb/blocks/schema/ddbexpr/DdbUpdateExprInterpreter.scala | Validates set update operands before constructing DynamoDB update actions. |
Review effort: Lite
googley42
marked this pull request as ready for review
November 29, 2026 11:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Under
withSchema1ByteCompatibility(ReadBothWriteOld), aputof a record with a non-emptySet[Byte]succeeded but stored the item without that attribute: the elements encode toBinary, theSet[numeric]branch kept onlyNumbers and produced an emptyNumberSet, and empty sets are left out of the item. And no mode, including the twoReadBoth*modes, could read the format 2.x wrote. Found from a review comment on #1167.2.x had no native
Set[Byte]: its set encoder has noByteTypecase, so it wrote aListof single-byteBinaryvalues.Change
Set[Byte]gets its own codec in the two compatibility modes; the default mode is unchanged.ReadNewWriteNew(default)NumberSetNumberSetReadBothWriteNewNumberSetNumberSet, or 2.x'sListof single-byteBinaryReadBothWriteOldListof single-byteBinary(an empty set is an emptyList, so it is kept)Also:
addSet/deleteFromSetnow fail in the effect, before a request is sent, when the field's codec doesn't encode the value as a set (as underReadBothWriteOld, where it is aList), like the numeric-update check added in #1167.containsElementkeeps working there, since DynamoDB'scontainsaccepts a list.Docs: a
Set[Byte]row in theSchema1Compattable indocs/reference/codec.md.Tests
DynamoDBCodecDeriverSpec("Schema1Compat Set[Byte]"): what each mode writes and reads, including the empty set and a malformed element.DdbExprNumericFieldsSpec:addSet/deleteFromSetfail under the legacy codec and are unaffected for other sets;containsElementon theListform.ByteSetCompatibilitySpec(against DynamoDB Local): underReadBothWriteOlda non-empty and an emptySet[Byte]round-trip and are stored as aList; underReadBothWriteNewan item stored in 2.x's format reads back.All suites pass on Scala 3.3.9 and 2.13.18, including
ceandit.