Skip to content

fix: handle non-array tags from bru parser to prevent crash#7616

Merged
bijin-bruno merged 1 commit intousebruno:mainfrom
abhishek-bruno:fix/bru-empty-tags-array-crash
Apr 1, 2026
Merged

fix: handle non-array tags from bru parser to prevent crash#7616
bijin-bruno merged 1 commit intousebruno:mainfrom
abhishek-bruno:fix/bru-empty-tags-array-crash

Conversation

@abhishek-bruno
Copy link
Copy Markdown
Member

@abhishek-bruno abhishek-bruno commented Mar 30, 2026

Description

JIRA

  • Fixes crash (v.map is not a function) when a .bru file contains tags: [] (inline empty array) in the meta block
  • The bru grammar requires newlines inside list brackets, so tags: [] gets parsed as the string "[]" instead of an empty array — this causes .map() calls in React components to crash
  • Adds Array.isArray guard when extracting tags in parseBruRequest

Fixes #7357

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

  • Bug Fixes
    • Fixed tag validation in Bru format file parsing to ensure tags are always properly formatted as arrays, preventing potential issues when processing files with malformed tag data.

Updated the parseBruRequest function to guarantee that the tags extracted from the JSON input are always returned as an array, improving data consistency and preventing potential errors when handling non-array values.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 30, 2026

Walkthrough

A bug fix in parseBruRequest that ensures transformedJson.tags is always an array. Previously, non-array values from meta.tags could propagate unchecked, causing application crashes when tags were present but malformed.

Changes

Cohort / File(s) Summary
Array Type Validation
packages/bruno-filestore/src/formats/bru/index.ts
Added array type guard to parseBruRequest to ensure tags defaults to an empty array if meta.tags exists but is not an array, preventing crashes on malformed metadata.

Estimated Code Review Effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested Labels

size/S

Suggested Reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

🏷️ Tags were crashing, oh what a sight,
When arrays went rogue in the .bru night,
A ternary guard came to save the day,
Empty arrays now safely stay! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Title accurately describes the main change: handling non-array tags from bru parser to prevent crashes.
Linked Issues check ✅ Passed Changes directly address issue #7357 by adding Array.isArray guard to ensure tags are arrays before usage, preventing the v.map crash.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the non-array tags issue; no unrelated modifications detected in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

@bijin-bruno bijin-bruno merged commit 3c3acf3 into usebruno:main Apr 1, 2026
12 checks passed
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.

Application is crash

2 participants