Skip to content

Conversation

@naman-bruno
Copy link
Collaborator

@naman-bruno naman-bruno commented Dec 6, 2025

Description

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

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

Release Notes

  • New Features
    • Added OpenCollection format support for exporting collections with a new export option in the Share Collection interface
    • Added OpenCollection format support for importing collections; the import dialog now recognizes and processes OpenCollection files

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 6, 2025

Walkthrough

This PR adds comprehensive OpenCollection format support to Bruno, enabling users to both import OpenCollection payloads and export Bruno collections in OpenCollection format. Changes span UI components, Redux actions, and new transformer utilities for bidirectional data conversion between Bruno and OpenCollection schemas.

Changes

Cohort / File(s) Summary
UI Components
packages/bruno-app/src/components/ShareCollection/index.js, packages/bruno-app/src/components/Sidebar/ImportCollection/index.js, packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js
Added OpenCollection UI block in ShareCollection with loading states; updated ImportCollection help text to include OpenCollection; added OpenCollection format detection and processing in ImportCollectionLocation.
Redux State Management
packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js
Integrated "opencollection" type into transformCollection switch, routing to processOpenCollection importer.
Export Utility
packages/bruno-app/src/utils/exporters/opencollection.js
New comprehensive exporter converting Bruno collections to OpenCollection schema with helpers for auth, headers, params, scripts, assertions, and metadata; exports to YAML format via FileSaver.
Import Utility
packages/bruno-app/src/utils/importers/opencollection.js
New importer with openCollectionToBruno converter, processOpenCollection async pipeline, and isOpenCollection validator; maps OpenCollection structures to Bruno equivalents with schema validation.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant UI as ImportCollection UI
    participant Redux as Redux<br/>(workspaces/actions)
    participant Importer as processOpenCollection
    participant Validator as Schema<br/>Validator
    participant Store as Collection<br/>Store

    User->>UI: Upload/Select OpenCollection file
    UI->>UI: Detect format (isOpenCollection)
    UI->>Redux: Dispatch transformCollection action
    
    rect rgb(220, 240, 250)
    Note over Redux,Store: Import Flow
    Redux->>Importer: Call processOpenCollection(jsonData)
    Importer->>Importer: openCollectionToBruno conversion
    Importer->>Importer: Hydrate & UID augmentation
    Importer->>Validator: Validate against schema
    Validator-->>Importer: Validation result
    end
    
    alt Valid
        Importer-->>Redux: Return Bruno collection
        Redux->>Store: Persist collection
        Store-->>User: Collection imported ✓
    else Invalid
        Importer-->>Redux: Throw BrunoError
        Redux-->>User: Error notification
    end
Loading
sequenceDiagram
    actor User
    participant UI as ShareCollection UI
    participant Handler as handleExportOpenCollection
    participant Exporter as brunoToOpenCollection
    participant Transformer as Schema<br/>Transformers
    participant FileSaver as YAML<br/>Export

    User->>UI: Click "Export OpenCollection"
    UI->>Handler: handleExportOpenCollection()
    Handler->>Handler: Clone collection
    Handler->>Exporter: brunoToOpenCollection(collection)
    
    rect rgb(240, 250, 220)
    Note over Exporter,Transformer: Transform Flow
    Exporter->>Transformer: Map auth, headers, items
    Exporter->>Transformer: Transform HTTP/GraphQL/gRPC/WS
    Exporter->>Transformer: Map variables, scripts, assertions
    Exporter->>Transformer: Aggregate environments & metadata
    Transformer-->>Exporter: Transformed OpenCollection object
    end
    
    Exporter-->>Handler: Return OpenCollection
    Handler->>FileSaver: exportCollection (YAML)
    FileSaver->>FileSaver: Serialize to YAML
    FileSaver-->>User: Download {collectionName}.yaml ✓
    Handler->>UI: Close modal
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Areas requiring extra attention:

  • packages/bruno-app/src/utils/exporters/opencollection.js — Dense transformation logic with multiple nested helper functions mapping Bruno schema to OpenCollection; verify correctness of all auth/header/parameter/script/assertion mappings and edge cases (null/undefined handling).
  • packages/bruno-app/src/utils/importers/opencollection.js — Reverse transformation pipeline with schema validation; review processOpenCollection async flow, UID augmentation logic, and BrunoError handling for robustness.
  • Redux integration in packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js — Ensure dynamic import and type routing aligns with existing patterns and error propagation.

Possibly related PRs

  • usebruno/bruno#6264 — Introduces or modifies workspaces initialization that may share state-management patterns with the new OpenCollection integration.

Suggested reviewers

  • lohit-bruno
  • bijin-bruno
  • helloanoop

Poem

A format new arrives to play,
OpenCollection finds its way,
Bruno imports and exports with grace,
YAML flows through cyberspace! 📦✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'export & import in opencollection format' directly and clearly describes the main changes—adding OpenCollection export and import functionality across multiple components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
packages/bruno-app/src/utils/exporters/opencollection.js (2)

750-757: Dead code: config.environments deletion is unreachable.

transformConfig never creates an environments property, so this check and deletion will never execute.

   const config = transformConfig(collection.brunoConfig);
   if (config) {
     openCollection.config = config;
-
-    if (config.environments) {
-      delete config.environments;
-    }
   }

797-811: Sanitize filename to prevent issues with special characters.

collection.name could contain characters invalid for filenames (e.g., /, \, :). Consider sanitizing before use.

+const sanitizeFilename = (name) => {
+  return (name || 'collection').replace(/[/\\:*?"<>|]/g, '_');
+};
+
 export const exportCollection = (collection) => {
   const openCollection = brunoToOpenCollection(collection);

   const yamlContent = jsyaml.dump(openCollection, {
     indent: 2,
     lineWidth: -1,
     noRefs: true,
     sortKeys: false
   });

-  const fileName = `${collection.name}.yml`;
+  const fileName = `${sanitizeFilename(collection.name)}.yml`;
   const fileBlob = new Blob([yamlContent], { type: 'application/x-yaml' });

   FileSaver.saveAs(fileBlob, fileName);
 };
packages/bruno-app/src/utils/importers/opencollection.js (3)

280-292: Minor edge case: array values.

Line 286 uses typeof v.value === 'object' which is also true for arrays. If v.value were an array, accessing .data would return undefined, falling back to ''. This works but relies on implicit behavior.

If arrays are never expected here, consider adding explicit handling for clarity:

-      value: typeof v.value === 'object' ? v.value.data || '' : v.value || '',
+      value: typeof v.value === 'object' && v.value !== null && !Array.isArray(v.value) ? v.value.data || '' : v.value || '',

605-628: Redundant condition.

Line 605: The && config.proxy !== false check is redundant since config.proxy being false would already fail the first condition.

-  if (config.proxy && config.proxy !== false) {
+  if (config.proxy) {

That said, if the explicit intent is to document that false is a valid sentinel value in OpenCollection, keeping it is acceptable for readability.


740-752: Original error context lost in BrunoError.

The catch block logs the original error but throws a generic BrunoError without the original message or cause. This can make debugging import failures difficult.

Consider including the original error message:

  } catch (err) {
    console.error('Error processing OpenCollection:', err);
-   throw new BrunoError('Import OpenCollection failed');
+   throw new BrunoError(`Import OpenCollection failed: ${err.message}`);
  }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a8d787 and 3e0a6db.

📒 Files selected for processing (6)
  • packages/bruno-app/src/components/ShareCollection/index.js (3 hunks)
  • packages/bruno-app/src/components/Sidebar/ImportCollection/index.js (3 hunks)
  • packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js (3 hunks)
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js (1 hunks)
  • packages/bruno-app/src/utils/exporters/opencollection.js (1 hunks)
  • packages/bruno-app/src/utils/importers/opencollection.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/utils/exporters/opencollection.js
  • packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js
  • packages/bruno-app/src/utils/importers/opencollection.js
  • packages/bruno-app/src/components/ShareCollection/index.js
  • packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js
  • packages/bruno-app/src/components/Sidebar/ImportCollection/index.js
🧬 Code graph analysis (5)
packages/bruno-app/src/utils/exporters/opencollection.js (1)
packages/bruno-app/src/utils/importers/opencollection.js (8)
  • transformItem (532-554)
  • transformFolder (491-530)
  • transformItems (556-560)
  • transformEnvironments (562-575)
  • root (658-658)
  • brunoConfig (578-583)
  • config (585-585)
  • collection (742-742)
packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js (1)
packages/bruno-app/src/utils/importers/opencollection.js (3)
  • collection (742-742)
  • processOpenCollection (740-752)
  • processOpenCollection (740-752)
packages/bruno-app/src/utils/importers/opencollection.js (2)
packages/bruno-app/src/utils/exporters/opencollection.js (20)
  • auth (324-324)
  • auth (423-423)
  • auth (481-481)
  • auth (536-536)
  • auth (592-592)
  • auth (657-657)
  • headers (315-315)
  • headers (410-410)
  • headers (514-514)
  • headers (591-591)
  • headers (654-654)
  • params (318-318)
  • params (413-413)
  • body (321-321)
  • variables (330-330)
  • variables (429-429)
  • variables (487-487)
  • variables (542-542)
  • variables (594-594)
  • variables (660-660)
packages/bruno-app/src/utils/common/error.js (1)
  • BrunoError (4-10)
packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js (1)
packages/bruno-app/src/utils/importers/opencollection.js (3)
  • processOpenCollection (740-752)
  • processOpenCollection (740-752)
  • collection (742-742)
packages/bruno-app/src/components/Sidebar/ImportCollection/index.js (1)
packages/bruno-app/src/utils/importers/opencollection.js (2)
  • isOpenCollection (754-768)
  • isOpenCollection (754-768)
⏰ 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). (6)
  • GitHub Check: SSL Tests - Windows
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: Unit Tests
  • GitHub Check: CLI Tests
🔇 Additional comments (24)
packages/bruno-app/src/utils/exporters/opencollection.js (5)

4-66: LGTM on auth transformation.

Comprehensive handling of all auth modes including basic, bearer, digest, NTLM, AWS v4, API key, WSSE, and OAuth2. The early returns for none and inherit modes are clean.


68-176: OAuth2 transformation covers all standard grant types.

Good coverage of client_credentials, password, authorization_code, and implicit flows with proper token configuration mapping.


178-251: Clean header, param, and body transformers.

Appropriate use of spread for optional properties. The body transformer handles all Bruno body modes including GraphQL bodies correctly.


304-397: HTTP request transformation is thorough.

Includes examples transformation with proper request/response mapping. All optional fields are conditionally added.


556-576: Verify item type mapping consistency with importer.

The switch cases use Bruno's internal types (http-request, graphql-request, etc.) while the transformation functions output OpenCollection types. Confirm the importer's transformItem correctly reverses this mapping (e.g., httphttp-request).

packages/bruno-app/src/components/Sidebar/ImportCollection/index.js (3)

11-11: LGTM on import addition.

Correct import path for the new OpenCollection validator.


76-77: Detection order is appropriate.

OpenCollection is checked after more specific formats (OpenAPI, WSDL, Postman, Insomnia) but before Bruno's native format. Since isOpenCollection checks for the opencollection version string property, this ordering prevents false positives.


165-165: Help text updated correctly.

Users are now informed that OpenCollection format is supported alongside other formats.

packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js (3)

11-11: LGTM on import.


40-41: Collection name extraction follows existing patterns.

Correctly accesses info.name with fallback to 'OpenCollection', consistent with other formats.


70-72: Conversion case correctly uses async processor.

processOpenCollection handles schema validation, UID hydration, and sequence numbering per the relevant snippet.

packages/bruno-app/src/providers/ReduxStore/slices/workspaces/actions.js (1)

37-40: LGTM on Redux action handler.

Follows established dynamic import pattern for code splitting, consistent with other collection types.

packages/bruno-app/src/components/ShareCollection/index.js (3)

3-3: LGTM on new imports.

IconFileExport is appropriate for a generic export action, differentiating from Bruno's logo and Postman's download icon.

Also applies to: 8-8


52-56: Export handler follows established pattern.

Uses transformCollectionToSaveToExportAsFile like Bruno export, ensuring consistent data preparation.


86-105: OpenCollection export UI is well-integrated.

No warning banner needed here since OpenCollection format supports gRPC and WebSocket requests (unlike Postman). Loading states and click handlers mirror existing export options.

packages/bruno-app/src/utils/importers/opencollection.js (9)

1-4: LGTM!

Imports are clean and all are utilized throughout the file.


6-196: LGTM!

Auth transformation covers all expected types including comprehensive OAuth2 flow handling. The nested helper functions for token/credentials placement are cleanly encapsulated.


318-394: LGTM!

HTTP and GraphQL item transformers are thorough. Examples handling correctly maps both request and response data. Default method for GraphQL being 'POST' is appropriate.


396-489: LGTM!

gRPC and WebSocket transformers handle both single-message and multi-message formats gracefully. Using metadata for gRPC headers is the correct OpenCollection convention.


532-560: LGTM!

The transformItem switch handles all expected types and gracefully returns null for unknown types, which transformItems filters out. Clean recursive pattern for nested structures.


562-575: LGTM!

Environment transformation correctly maps OpenCollection's transient property to Bruno's secret field.


681-692: LGTM!

openCollectionToBruno cleanly orchestrates the conversion by delegating to specialized transform functions. Good separation of concerns.


694-738: LGTM!

Recursive UID assignment for root and nested folder roots is correct. The mutation pattern is consistent with the related updateUidsInCollection utility.


754-768: LGTM!

isOpenCollection provides robust structural validation for format detection. The checks for required opencollection string and info object are appropriate guards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant