-
Notifications
You must be signed in to change notification settings - Fork 9
feat(runner): create data URIs for array element objects not marked asCell #1920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…sCell When getting array elements as cells, plain objects (not marked with asCell or asStream) now receive immutable data URIs instead of array index paths. This provides stable references while preventing mutation loops when reassigning array elements. Changes: - Array element objects get data URIs with empty paths - Nested documents (marked asCell) continue to use of: URIs as before - Only create array index references when element is already a link - Update tests to reflect new data URI behavior for plain objects - Change createDataCellURI return type from string to URI for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates array element handling in the schema runner to assign immutable data URIs to plain object elements (not marked asCell/asStream), improving link stability and avoiding mutation loops.
- Switch array element link detection to parse the in-memory element value and create data URIs for plain objects
- Change createDataCellURI return type to URI for consistency
- Update tests to expect data URIs for plain object elements and adopt setRaw in setup
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/runner/src/schema.ts | Implements data URI creation for plain object array elements and adjusts link parsing logic. |
| packages/runner/src/link-utils.ts | Changes createDataCellURI return type from string to URI. |
| packages/runner/test/schema.test.ts | Updates tests to reflect data URI behavior and uses setRaw in test setup. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 3 files
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="packages/runner/test/schema.test.ts">
<violation number="1" location="packages/runner/test/schema.test.ts:1454">
setRaw serializes the input and cannot handle RegularCell instances; this call will throw and leave the VDOM fixture unset, so the test no longer exercises the intended linked-data path.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 1 file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 2 files
Changed from base64 encoding to URL encoding (encodeURIComponent) for data URIs to handle UTF-8 characters properly. This matches the pattern already used in runtime.ts and avoids the btoa() Latin1 limitation. Changes: - createDataCellURI() now uses encodeURIComponent instead of base64 - getJSONFromDataURI() already handles both formats (base64 and URL-encoded) - Update tests to use getJSONFromDataURI() instead of manual atob() decoding - Add comprehensive test for UTF-8 character support This fixes integration test failures where recipes containing non-ASCII characters (emojis, Chinese, Arabic, etc.) would cause data URI creation to fail with "characters outside of the Latin1 range" error. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
9d19646 to
fe0e36b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 3 files
…sCell
When getting array elements as cells, plain objects (not marked with asCell or asStream) now receive immutable data URIs instead of array index paths. This provides stable references while preventing mutation loops when reassigning array elements.
Changes:
Summary by cubic
Array elements that are plain objects (not marked as asCell/asStream) are now returned as immutable data: URIs with empty paths instead of array index links. This stabilizes references and prevents mutation loops when arrays are reordered or reassigned.
New Features
Migration