-
Notifications
You must be signed in to change notification settings - Fork 4
fix: Avoid overflows when saving files with large outputs #239
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
📝 WalkthroughWalkthroughUpdates the Deepnote notebook serialization pipeline to handle edge cases in binary data and object references. Adds a chunked base64 converter to prevent stack overflow when encoding large image outputs. Introduces a deep clone helper that removes true circular references while preserving shared structure. Refactors serialization to validate project/notebook context, convert cells to blocks, clone blocks to remove circular refs, update project metadata.modifiedAt, and emit YAML from the mutated original project. Expands unit tests to cover large binary outputs and circular-reference-containing outputs. Pre-merge checks✅ Passed checks (5 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (4)**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.ts📄 CodeRabbit inference engine (.github/instructions/typescript.instructions.md)
Files:
src/**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
src/notebooks/deepnote/**/*.ts📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧬 Code graph analysis (1)src/notebooks/deepnote/deepnoteSerializer.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (5)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #239 +/- ##
===========================
===========================
🚀 New features to boost your workflow:
|
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
src/notebooks/deepnote/deepnoteDataConverter.ts(2 hunks)src/notebooks/deepnote/deepnoteDataConverter.unit.test.ts(2 hunks)src/notebooks/deepnote/deepnoteSerializer.ts(2 hunks)src/notebooks/deepnote/deepnoteSerializer.unit.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.unit.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Create unit tests in
*.unit.test.tsfiles
**/*.unit.test.ts: Unit tests use Mocha/Chai framework with.unit.test.tsextension
Test files should be placed alongside the source files they test
Useassert.deepStrictEqual()for object comparisons instead of checking individual properties
Files:
src/notebooks/deepnote/deepnoteSerializer.unit.test.tssrc/notebooks/deepnote/deepnoteDataConverter.unit.test.ts
**/*.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Create integration tests in
*.test.tsfiles (not*.unit.test.ts)
**/*.test.ts: ALWAYS check the 'Unittest - Build' task output for TypeScript compilation errors before running any script or declaring work complete
When a mock is returned from a promise in unit tests, ensure the mocked instance has an undefinedthenproperty to avoid hanging tests
Usenpm run test:unittestsfor TypeScript unit tests before committing changes
Files:
src/notebooks/deepnote/deepnoteSerializer.unit.test.tssrc/notebooks/deepnote/deepnoteDataConverter.unit.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Usel10n.t()for all user-facing strings in TypeScript files
Use typed error classes fromsrc/platform/errors/instead of generic errors
UseILoggerservice instead of console.log for logging
Preserve error details in error messages while scrubbing personally identifiable information (PII)
Prefer async/await over promise chains
Handle cancellation with CancellationTokenOrder method, fields and properties first by accessibility (public/private/protected) and then by alphabetical order
Files:
src/notebooks/deepnote/deepnoteSerializer.unit.test.tssrc/notebooks/deepnote/deepnoteDataConverter.unit.test.tssrc/notebooks/deepnote/deepnoteSerializer.tssrc/notebooks/deepnote/deepnoteDataConverter.ts
**/*.ts
📄 CodeRabbit inference engine (.github/instructions/typescript.instructions.md)
**/*.ts: ALWAYS check the 'Core - Build' task output for TypeScript compilation errors before running any script or declaring work complete
ALWAYS runnpm run format-fixbefore committing changes to ensure proper code formatting
FIX all TypeScript compilation errors before moving forward with development
Usenpm run format-fixto auto-fix TypeScript formatting issues before committing
Usenpm run lintto check for linter issues in TypeScript files and attempt to fix before committing
Files:
src/notebooks/deepnote/deepnoteSerializer.unit.test.tssrc/notebooks/deepnote/deepnoteDataConverter.unit.test.tssrc/notebooks/deepnote/deepnoteSerializer.tssrc/notebooks/deepnote/deepnoteDataConverter.ts
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
src/**/*.{ts,tsx}: Don't add the Microsoft copyright header to new files
UseUri.joinPath()for constructing file paths instead of string concatenation with/to ensure platform-correct path separators
Follow established patterns when importing new packages, using helper imports rather than direct imports (e.g., useimport { generateUuid } from '../platform/common/uuid'instead of importing uuid directly)
Add blank lines after const groups and before return statements for readability
Separate third-party and local file imports
Files:
src/notebooks/deepnote/deepnoteSerializer.unit.test.tssrc/notebooks/deepnote/deepnoteDataConverter.unit.test.tssrc/notebooks/deepnote/deepnoteSerializer.tssrc/notebooks/deepnote/deepnoteDataConverter.ts
src/notebooks/deepnote/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Deepnote integration located in
src/notebooks/deepnote/with refactored architecture:deepnoteTypes.ts(type definitions),deepnoteNotebookManager.ts(state management),deepnoteNotebookSelector.ts(UI selection logic),deepnoteDataConverter.ts(data transformations),deepnoteSerializer.ts(main serializer/orchestration),deepnoteActivationService.ts(VSCode activation)
Files:
src/notebooks/deepnote/deepnoteSerializer.unit.test.tssrc/notebooks/deepnote/deepnoteDataConverter.unit.test.tssrc/notebooks/deepnote/deepnoteSerializer.tssrc/notebooks/deepnote/deepnoteDataConverter.ts
🧬 Code graph analysis (2)
src/notebooks/deepnote/deepnoteDataConverter.unit.test.ts (1)
src/test/mocks/vsc/extHostedTypes.ts (3)
NotebookCellData(2546-2572)NotebookCellOutput(71-103)NotebookCellOutputItem(16-69)
src/notebooks/deepnote/deepnoteSerializer.ts (2)
src/platform/logging/index.ts (1)
logger(35-48)src/platform/deepnote/deepnoteTypes.ts (2)
DeepnoteFile(6-6)DeepnoteBlock(6-6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build & Test
🔇 Additional comments (5)
src/notebooks/deepnote/deepnoteSerializer.unit.test.ts (1)
328-397: Good targeted regression test for circular output metadataThis suite cleanly reproduces the circular
metadata.selfscenario and verifies thatserializeNotebookno longer blows up while still emitting valid YAML containing the project ID. Coverage looks appropriate for the circular‑reference fix.src/notebooks/deepnote/deepnoteDataConverter.unit.test.ts (2)
2-2: Importing notebook output types is consistent with the converter’s expectationsBringing in
NotebookCellOutputandNotebookCellOutputItemfromvscodelets the tests construct outputs with the same shape the converter handles, which keeps these tests close to real usage.
801-846: Large image output test covers the stack‑overflow regression wellThe 1MB
Uint8Arraysetup and subsequent assertions that a single code block with a base64‑encoded'image/png'payload is produced give solid coverage for large binary outputs without over‑asserting internals.src/notebooks/deepnote/deepnoteDataConverter.ts (1)
527-542: Chunkeduint8ArrayToBase64implementation is appropriate for large outputsThe chunked loop with
chunkSize = 8192avoids the previous argument explosion while preserving the straightforwardbtoa(binaryString)behavior. Given the 1MB test coverage, this looks sufficient for typical Deepnote outputs without introducing unnecessary complexity.src/notebooks/deepnote/deepnoteSerializer.ts (1)
139-195: Updated serialize path and logging align with circular‑ref and overflow fixesThe added debug logging around project/notebook resolution, block conversion, and YAML dumping is useful and stays within the logger abstraction. Converting cells -> blocks, then assigning
notebook.blocks = cloneWithoutCircularRefs<DeepnoteBlock[]>(blocks)before updatingmetadata.modifiedAtand callingyaml.dumpis a sensible way to both drop problematic cycles and keep the original project structure intact. This ties in well with the new circular‑reference test and the large‑output handling in the converter.
Fixes #238
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.