[CDX 339] Add support for "format" query parameter#251
Conversation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/modules/catalog.js:70
formatis validated after potentially convertingitems/variations/itemGroupsstreams into buffers. If a caller passes an invalidformat, this will still read the entire stream into memory before failing, which is unnecessary work and can be expensive for large uploads. Consider validating/normalizingformatimmediately after destructuring parameters (before any stream-to-buffer conversion) so invalid values fail fast.
const { section, notification_email, notificationEmail = notification_email, force, item_groups, onMissing, format = 'csv' } = parameters;
let { items, variations, itemGroups = item_groups } = parameters;
try {
// Convert items to buffer if passed as stream
if (items instanceof fs.ReadStream || items instanceof Duplex) {
items = await convertToBuffer(items);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This PR adds a format query parameter (csv | jsonl) to all six catalog ingestion methods (replaceCatalog, updateCatalog, patchCatalog, and the three *UsingTarArchive variants), defaulting to csv for backwards compatibility, with comprehensive test coverage.
Inline comments: 5 discussions added
Overall Assessment:
| section: 'Products', | ||
| }; | ||
|
|
||
| catalog.replaceCatalog(data).then((res) => { |
There was a problem hiding this comment.
Important Issue: All new done-callback tests use .then() without a .catch(done) chain. If the promise rejects (e.g., a network error or unexpected server response), Mocha will silently time out instead of reporting the real failure. Add .catch(done) to each .then() block, or convert to async/await:
catalog.replaceCatalog(data).then((res) => {
// assertions...
done();
}).catch(done);This applies to all eight new done-style tests across the four describe blocks.
No description provided.