Repository navigation
feat(import): enhance import functionality with issue tracking and logging - #8098
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThis PR adds diagnostic issue tracking to Postman collection imports. The converter now accumulates skipped/invalid items as structured issues (errors and warnings) and returns them alongside the converted collection. A new toast UI displays these issues with copy and GitHub reporting actions, integrated into both single and bulk import flows. ChangesPostman Import Issues Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 9
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/bruno-app/src/components/Sidebar/BulkImportCollectionLocation/index.js`:
- Around line 661-666: The clipboard write in the onClick handler for the
BulkImportCollectionLocation component is not awaited or error-handled, so it
always shows "Copied to clipboard"; make the onClick handler async, await
navigator.clipboard.writeText(text) (where text is built from
importIssues[collection.uid].map(...).join('\n')), wrap the await in try/catch,
call toast.success only on successful completion and call toast.error (or
equivalent) in the catch with a clear message; ensure you reference the same
handler that constructs text and uses navigator.clipboard.writeText.
- Around line 329-334: The current issues.forEach block is pushing raw
issue.sourceItem into logArgs and dispatching addLog (in the
BulkImportCollectionLocation component), which can leak sensitive payloads;
remove passing issue.sourceItem to dispatch/addLog or replace it with a
sanitized/redacted version (e.g., include only allowed fields or a boolean flag
like hasSourceItem) before calling dispatch(addLog({ type: logType, args:
logArgs, timestamp })); update the code around issues.forEach / allIssues push
so allIssues may still keep full data if needed but logs only contain
path/message or a redactedSourceItem to avoid exposing tokens/keys/internal
URLs.
- Around line 172-183: The useEffect that builds issuesMap (inside useEffect
using isBulkImport, importData and importedCollectionFromBulk) only calls
setImportIssues when issuesMap is non-empty, so stale issues persist; after
computing issuesMap always update state—call setImportIssues(issuesMap) if
non-empty, otherwise call setImportIssues({}) (or null depending on component
expectations) to clear previous issues so importIssues reflects the current
importData.
In `@packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js`:
- Around line 187-191: The code in issues.forEach is pushing raw
issue.sourceItem into internal logs (see issue.sourceItem and dispatch(addLog)),
which may contain PII/secrets; update the logging so you only include
non-sensitive metadata (e.g., path, id, type) or a redacted/masked version of
sourceItem before calling dispatch(addLog), and ensure any full payload is only
logged when an explicit user opt-in flag is set (check a feature flag or user
preference) — change the logic that currently does "if (issue.sourceItem)
logArgs.push(issue.sourceItem)" to add a sanitized object or masked string
instead and respect the opt-in flag.
In `@packages/bruno-app/src/components/Toast/ActionableToast/index.js`:
- Around line 34-35: The close control button in ActionableToast is icon-only
and lacks an accessible name and explicit type; update the button element (the
one with className "toast-close" that calls toast.dismiss(t.id) and renders
<IconX />) to include aria-label="Close toast" and type="button" so it has an
accessible name and safe button behavior.
In `@packages/bruno-app/src/components/Toast/ImportIssuesToast/index.js`:
- Around line 68-88: Add stable test selectors to the new interactive elements
by adding data-testid attributes: add data-testid="include-items-checkbox" to
the input checkbox (the element using includeItems and setIncludeItems), add
data-testid="report-on-github-button" to the button invoking handleReport, and
add data-testid="copy-issues-button" to the button invoking handleCopy; ensure
attributes are applied to the exact JSX elements shown (the <input ...
checked={includeItems} ...>, the Report on GitHub button with IconBrandGithub,
and the Copy Issues button with IconCopy) so Playwright can reliably select
them.
- Around line 25-38: The handleCopy function currently calls
navigator.clipboard.writeText without awaiting or handling failures but always
shows toast.success; make handleCopy async, await
navigator.clipboard.writeText(text) inside a try/catch, call toast.success(...)
only on successful await, and call toast.error(...) (or similar failure
handling) in the catch block so clipboard permission/availability errors are
reported instead of always showing success; refer to handleCopy,
navigator.clipboard.writeText, and toast.success/toast.error when applying the
change.
In `@packages/bruno-converters/src/postman/postman-to-bruno.js`:
- Around line 371-375: Guard against null/primitive entries before branching on
folder vs request: inside the item.forEach loop, before computing
itemName/itemPath or calling isItemAFolder(i), check that i is a non-null object
(e.g. if (typeof i !== 'object' || i === null) { /* record an import issue for
this malformed entry and return/continue */ }). Update the logic around
item.forEach, itemName, itemPath and the isItemAFolder(i) call to continue past
malformed entries and ensure you record an error/issue for that entry so the
rest of the collection import proceeds.
- Around line 437-440: The code currently calls
i?.request?.method?.toUpperCase() which can throw if method exists but is not a
string; change the logic in the block around method (the expression
i?.request?.method?.toUpperCase() and the const method) to first read rawMethod
= i?.request?.method, validate typeof rawMethod === 'string' and that
rawMethod.trim() is non-empty, then set method = rawMethod.toUpperCase(); if
validation fails push the same issue ({ path: itemPath, severity: 'error',
message: 'Missing or invalid request method', sourceItem: i }) and return; this
ensures no runtime error before issues.push is reached.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: fc84ba86-bddf-48e4-ad22-ebdacdd45648
📒 Files selected for processing (15)
packages/bruno-app/src/components/Sidebar/BulkImportCollectionLocation/index.jspackages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.jspackages/bruno-app/src/components/Toast/ActionableToast/StyledWrapper.jspackages/bruno-app/src/components/Toast/ActionableToast/index.jspackages/bruno-app/src/components/Toast/ImportIssuesToast/StyledWrapper.jspackages/bruno-app/src/components/Toast/ImportIssuesToast/index.jspackages/bruno-converters/src/postman/postman-to-bruno.jspackages/bruno-converters/tests/postman-with-examples.spec.jspackages/bruno-converters/tests/postman/postman-to-bruno/collection-auth.spec.jspackages/bruno-converters/tests/postman/postman-to-bruno/folder-auth.spec.jspackages/bruno-converters/tests/postman/postman-to-bruno/partial-import.spec.jspackages/bruno-converters/tests/postman/postman-to-bruno/postman-to-bruno.spec.jspackages/bruno-converters/tests/postman/postman-to-bruno/request-auth.spec.jspackages/bruno-converters/tests/postman/postman-to-bruno/transform-description.spec.jspackages/bruno-electron/src/ipc/collection.js
There was a problem hiding this comment.
♻️ Duplicate comments (2)
packages/bruno-app/src/components/Toast/ImportIssuesToast/index.js (1)
25-38:⚠️ Potential issue | 🟠 Major | ⚡ Quick winHandle clipboard errors before showing success feedback.
Line 36-37 still reports success even if
navigator.clipboard.writeTextfails (permission/availability/runtime).Suggested fix
- const handleCopy = () => { + const handleCopy = async () => { let text = issuesSummary; if (includeItems) { const itemsWithSource = issues.filter((i) => i.sourceItem); if (itemsWithSource.length > 0) { const itemsText = itemsWithSource .map((i) => `// ${i.path}\n${JSON.stringify(i.sourceItem, null, 2)}`) .join('\n\n'); text += `\n\nFailed Items:\n${itemsText}`; } } - navigator.clipboard.writeText(text); - toast.success('Copied to clipboard', { duration: 2000 }); + try { + await navigator.clipboard.writeText(text); + toast.success('Copied to clipboard', { duration: 2000 }); + } catch { + toast.error('Failed to copy issues', { duration: 3000 }); + } };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/components/Toast/ImportIssuesToast/index.js` around lines 25 - 38, The handleCopy function calls navigator.clipboard.writeText and immediately shows toast.success even if the write fails; modify handleCopy to await navigator.clipboard.writeText (or use its returned Promise) inside a try/catch, show toast.success only on success, and on failure call toast.error with a helpful message; also guard for navigator.clipboard existence (fallback or error) so handleCopy gracefully handles permission/unavailability and reports failure instead of always reporting success.packages/bruno-app/src/components/Toast/ActionableToast/index.js (1)
36-40:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAdd explicit button semantics for the close control.
Line 36-40 still renders an icon-only button without an accessible name and explicit
type='button'.Suggested fix
<button + type='button' + aria-label='Close toast' className="toast-close" data-testid={testId ? `${testId}-close` : undefined} onClick={() => toast.dismiss(t.id)} >🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/components/Toast/ActionableToast/index.js` around lines 36 - 40, The close control in ActionableToast renders an icon-only button without an explicit type or accessible name; update the button in the ActionableToast component so it includes type="button" and an accessible name (e.g., aria-label="Close" or visually hidden text) so screen readers can identify it, keeping the existing data-testid and onClick={() => toast.dismiss(t.id)} behavior intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@packages/bruno-app/src/components/Toast/ActionableToast/index.js`:
- Around line 36-40: The close control in ActionableToast renders an icon-only
button without an explicit type or accessible name; update the button in the
ActionableToast component so it includes type="button" and an accessible name
(e.g., aria-label="Close" or visually hidden text) so screen readers can
identify it, keeping the existing data-testid and onClick={() =>
toast.dismiss(t.id)} behavior intact.
In `@packages/bruno-app/src/components/Toast/ImportIssuesToast/index.js`:
- Around line 25-38: The handleCopy function calls navigator.clipboard.writeText
and immediately shows toast.success even if the write fails; modify handleCopy
to await navigator.clipboard.writeText (or use its returned Promise) inside a
try/catch, show toast.success only on success, and on failure call toast.error
with a helpful message; also guard for navigator.clipboard existence (fallback
or error) so handleCopy gracefully handles permission/unavailability and reports
failure instead of always reporting success.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ebabb5aa-0e8d-4aef-b78f-162e800c6786
📒 Files selected for processing (7)
packages/bruno-app/src/components/Toast/ActionableToast/index.jspackages/bruno-app/src/components/Toast/ImportIssuesToast/index.jspackages/bruno-converters/tests/fixtures/postman-with-import-issues.jsontests/import/postman/fixtures/postman-with-import-issues.jsontests/import/postman/import-partial-collection.spec.tstests/utils/page/actions.tstests/utils/page/locators.ts
✅ Files skipped from review due to trivial changes (2)
- packages/bruno-converters/tests/fixtures/postman-with-import-issues.json
- tests/import/postman/import-partial-collection.spec.ts
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-app/src/components/Sidebar/BulkImportCollectionLocation/index.js (1)
667-682:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAdd a stable
data-testidto the new Copy action.This new interactive control should expose a deterministic selector for Playwright coverage.
- <button + <button + data-testid="bulk-import-issues-copy-btn" onClick={async () => {As per coding guidelines, "Add
data-testidto testable elements for Playwright in React components".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-app/src/components/Sidebar/BulkImportCollectionLocation/index.js` around lines 667 - 682, The Copy button that builds text from importIssues[collection.uid] needs a deterministic test selector; add a data-testid attribute on the <button> in the onClick block (the Copy action) using a stable value that includes the collection identifier (e.g., "bulk-import-copy-<collection.uid>" or similar) so Playwright can reliably target it; update the JSX for the button in BulkImportCollectionLocation's Copy action to include this data-testid attribute without changing behavior or styling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/bruno-app/src/components/Sidebar/BulkImportCollectionLocation/index.js`:
- Around line 332-334: The summary header currently always logs with type
'error'; change it to pick a severity based on the collected parts so warnings
aren't misclassified. Compute a severity variable (e.g. const severity =
parts.some(p => /error/i.test(p)) ? 'error' : parts.some(p =>
/warn|warning/i.test(p)) ? 'warning' : 'info') and pass that severity to
dispatch(addLog(...)) instead of the hard-coded 'error' (referencing addLog,
dispatch, parts, name, timestamp).
---
Outside diff comments:
In
`@packages/bruno-app/src/components/Sidebar/BulkImportCollectionLocation/index.js`:
- Around line 667-682: The Copy button that builds text from
importIssues[collection.uid] needs a deterministic test selector; add a
data-testid attribute on the <button> in the onClick block (the Copy action)
using a stable value that includes the collection identifier (e.g.,
"bulk-import-copy-<collection.uid>" or similar) so Playwright can reliably
target it; update the JSX for the button in BulkImportCollectionLocation's Copy
action to include this data-testid attribute without changing behavior or
styling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1c811c5b-4db1-4187-9f6f-1786352b0be5
📒 Files selected for processing (4)
packages/bruno-app/src/components/Sidebar/BulkImportCollectionLocation/index.jspackages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.jspackages/bruno-app/src/components/Toast/ImportIssuesToast/StyledWrapper.jspackages/bruno-app/src/components/Toast/ImportIssuesToast/index.js
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/bruno-app/src/components/Toast/ImportIssuesToast/StyledWrapper.js
- packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js
- Updated the import process to return both collections and issues for better error handling. - Introduced a new toast notification for displaying import issues, allowing users to copy or report them. - Enhanced logging for import issues, capturing errors and warnings during the import process. - Added new components for actionable toasts and import issues display. - Updated tests to validate the new import behavior and issue tracking.
… tests - Added optional testId prop to ActionableToast for better test targeting. - Updated ImportIssuesToast to include data-testid attributes for improved e2e testing. - Introduced a new Postman collection fixture to test partial import scenarios. - Created new tests to validate the import process, including issue reporting and copying functionality. - Implemented utility functions to manage import issues toasts during tests.
…re robustly - Updated BulkImportCollectionLocation to always set import issues, ensuring consistent state management. - Enhanced clipboard copy functionality in ImportIssuesToast and BulkImportCollectionLocation to handle errors gracefully with user feedback. - Added aria-label for better accessibility in ActionableToast close button.
- Improved logging in BulkImportCollectionLocation and ImportCollectionLocation to provide detailed summaries of import issues, including counts of skipped items and warnings. - Updated ImportIssuesToast to handle long issue descriptions and provide user feedback for copying issue details to the clipboard. - Removed ActionableToast component and its styles, consolidating toast functionality within ImportIssuesToast for better maintainability. - Enhanced styling for ImportIssuesToast to improve user experience and accessibility.
…ionLocation and ImportCollectionLocation - Changed log type from 'error' to 'warn' for import issue summaries in both components to better reflect the severity of the messages. - This adjustment improves clarity in the logging system and aligns with the intended handling of import warnings.
cf143f1 to
cf8f1cb
Compare
…mprovements - Added an alert icon and improved styling for the URL-too-long warning in ImportIssuesToast to enhance user experience. - Introduced a new test for verifying the display of the URL length warning when importing collections with many issues. - Updated locators to include a test ID for the URL-too-long warning, facilitating better end-to-end testing.
- Changed background and border colors in StyledWrapper for better visual consistency. - Enhanced box-shadow and close button styles for improved accessibility and interaction. - Adjusted padding and gap in warning messages for better layout and readability.
…gging (usebruno#8098) * feat: enhance import functionality with issue tracking and logging - Updated the import process to return both collections and issues for better error handling. - Introduced a new toast notification for displaying import issues, allowing users to copy or report them. - Enhanced logging for import issues, capturing errors and warnings during the import process. - Added new components for actionable toasts and import issues display. - Updated tests to validate the new import behavior and issue tracking. * feat: enhance import issues handling with new toast notifications and tests - Added optional testId prop to ActionableToast for better test targeting. - Updated ImportIssuesToast to include data-testid attributes for improved e2e testing. - Introduced a new Postman collection fixture to test partial import scenarios. - Created new tests to validate the import process, including issue reporting and copying functionality. - Implemented utility functions to manage import issues toasts during tests. * fix: improve clipboard copy functionality and handle import issues more robustly - Updated BulkImportCollectionLocation to always set import issues, ensuring consistent state management. - Enhanced clipboard copy functionality in ImportIssuesToast and BulkImportCollectionLocation to handle errors gracefully with user feedback. - Added aria-label for better accessibility in ActionableToast close button. * refactor: enhance import issue logging and toast notifications - Improved logging in BulkImportCollectionLocation and ImportCollectionLocation to provide detailed summaries of import issues, including counts of skipped items and warnings. - Updated ImportIssuesToast to handle long issue descriptions and provide user feedback for copying issue details to the clipboard. - Removed ActionableToast component and its styles, consolidating toast functionality within ImportIssuesToast for better maintainability. - Enhanced styling for ImportIssuesToast to improve user experience and accessibility. * refactor: update logging level for import issues in BulkImportCollectionLocation and ImportCollectionLocation - Changed log type from 'error' to 'warn' for import issue summaries in both components to better reflect the severity of the messages. - This adjustment improves clarity in the logging system and aligns with the intended handling of import warnings. * feat: enhance ImportIssuesToast with URL length warning and styling improvements - Added an alert icon and improved styling for the URL-too-long warning in ImportIssuesToast to enhance user experience. - Introduced a new test for verifying the display of the URL length warning when importing collections with many issues. - Updated locators to include a test ID for the URL-too-long warning, facilitating better end-to-end testing. * style: update ImportIssuesToast styling for improved user experience - Changed background and border colors in StyledWrapper for better visual consistency. - Enhanced box-shadow and close button styles for improved accessibility and interaction. - Adjusted padding and gap in warning messages for better layout and readability.
…gging (usebruno#8098) * feat: enhance import functionality with issue tracking and logging - Updated the import process to return both collections and issues for better error handling. - Introduced a new toast notification for displaying import issues, allowing users to copy or report them. - Enhanced logging for import issues, capturing errors and warnings during the import process. - Added new components for actionable toasts and import issues display. - Updated tests to validate the new import behavior and issue tracking. * feat: enhance import issues handling with new toast notifications and tests - Added optional testId prop to ActionableToast for better test targeting. - Updated ImportIssuesToast to include data-testid attributes for improved e2e testing. - Introduced a new Postman collection fixture to test partial import scenarios. - Created new tests to validate the import process, including issue reporting and copying functionality. - Implemented utility functions to manage import issues toasts during tests. * fix: improve clipboard copy functionality and handle import issues more robustly - Updated BulkImportCollectionLocation to always set import issues, ensuring consistent state management. - Enhanced clipboard copy functionality in ImportIssuesToast and BulkImportCollectionLocation to handle errors gracefully with user feedback. - Added aria-label for better accessibility in ActionableToast close button. * refactor: enhance import issue logging and toast notifications - Improved logging in BulkImportCollectionLocation and ImportCollectionLocation to provide detailed summaries of import issues, including counts of skipped items and warnings. - Updated ImportIssuesToast to handle long issue descriptions and provide user feedback for copying issue details to the clipboard. - Removed ActionableToast component and its styles, consolidating toast functionality within ImportIssuesToast for better maintainability. - Enhanced styling for ImportIssuesToast to improve user experience and accessibility. * refactor: update logging level for import issues in BulkImportCollectionLocation and ImportCollectionLocation - Changed log type from 'error' to 'warn' for import issue summaries in both components to better reflect the severity of the messages. - This adjustment improves clarity in the logging system and aligns with the intended handling of import warnings. * feat: enhance ImportIssuesToast with URL length warning and styling improvements - Added an alert icon and improved styling for the URL-too-long warning in ImportIssuesToast to enhance user experience. - Introduced a new test for verifying the display of the URL length warning when importing collections with many issues. - Updated locators to include a test ID for the URL-too-long warning, facilitating better end-to-end testing. * style: update ImportIssuesToast styling for improved user experience - Changed background and border colors in StyledWrapper for better visual consistency. - Enhanced box-shadow and close button styles for improved accessibility and interaction. - Adjusted padding and gap in warning messages for better layout and readability.
JIRA
Screen.Recording.2026-05-25.at.11.52.06.PM.mov
Description
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit
New Features
Bug Fixes
Tests