Skip to content

Fix color tuple JSON round-trip in BackgroundLayer#7

Merged
sjquant merged 2 commits intomainfrom
claude/start-next-task-4K96t
Apr 2, 2026
Merged

Fix color tuple JSON round-trip in BackgroundLayer#7
sjquant merged 2 commits intomainfrom
claude/start-next-task-4K96t

Conversation

@sjquant
Copy link
Copy Markdown
Owner

@sjquant sjquant commented Apr 2, 2026

RGB/RGBA tuples stored in BackgroundLayer.color were serialized as JSON
arrays (e.g. [255, 87, 51]) instead of hex strings ("#FF5733"), making
the output non-spec-compliant and breaking interoperability with external
consumers that expect hex color strings.

Added a field_serializer on BackgroundLayer.color that converts tuples to
uppercase hex strings on serialization. from_json continues to accept the
hex output, completing the round-trip.

https://claude.ai/code/session_01RFcfvNpAKSAqYFX8FqpnD9

claude added 2 commits April 2, 2026 11:50
RGB/RGBA tuples stored in BackgroundLayer.color were serialized as JSON
arrays (e.g. [255, 87, 51]) instead of hex strings ("#FF5733"), making
the output non-spec-compliant and breaking interoperability with external
consumers that expect hex color strings.

Added a field_serializer on BackgroundLayer.color that converts tuples to
uppercase hex strings on serialization. from_json continues to accept the
hex output, completing the round-trip.

https://claude.ai/code/session_01RFcfvNpAKSAqYFX8FqpnD9
…nge validation

- test: extend serialization test with from_json round-trip assertion
  confirming tuple colors deserialise as hex strings, not tuples
- fix: wrap os.remove(stale_cache) in try/except OSError so a
  locked/read-only file on Windows doesn't crash with an unexpected error
- fix: validate that each channel in a tuple color is an int in 0–255;
  previously (256, 0, 0) was accepted and silently produced a malformed
  hex string in the serialiser

https://claude.ai/code/session_01RFcfvNpAKSAqYFX8FqpnD9
@sjquant sjquant merged commit 1f54441 into main Apr 2, 2026
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