Repository navigation
fix: crash when saving empty GraphQL query in YAML collections - #6453
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThis PR standardizes GraphQL field handling by converting undefined/null values to empty strings in both the UI component (GraphQLRequestPane) and the file format parser (parseGraphQLRequest.ts), along with adding a timing adjustment in test utilities. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
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: 0
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/RequestPane/QueryUrl/index.js (1)
147-159: Inconsistent behavior with HTTP paste handler.The GraphQL paste handler always dispatches variables (even when empty string), while the HTTP paste handler at line 276 only dispatches non-empty, non-whitespace variables. Consider applying the same trim check here for consistency.
🔎 Apply this diff for consistent handling:
let variables = request.body.graphql.variables || ''; -if (variables) { +if (variables && variables.trim()) { try { variables = JSON.parse(variables); } catch (error) { // Keep variables as-is if JSON parsing fails } + dispatch(updateRequestGraphqlVariables({ + itemUid: item.uid, + collectionUid: collection.uid, + variables: variables + })); } -dispatch(updateRequestGraphqlVariables({ - itemUid: item.uid, - collectionUid: collection.uid, - variables: variables -}));
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/bruno-app/src/components/RequestPane/GraphQLRequestPane/index.js(1 hunks)packages/bruno-app/src/components/RequestPane/QueryUrl/index.js(2 hunks)packages/bruno-filestore/src/formats/yml/items/parseGraphQLRequest.ts(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()notfunc ()
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/components/RequestPane/GraphQLRequestPane/index.jspackages/bruno-filestore/src/formats/yml/items/parseGraphQLRequest.tspackages/bruno-app/src/components/RequestPane/QueryUrl/index.js
🧠 Learnings (1)
📚 Learning: 2025-12-17T21:41:24.730Z
Learnt from: naman-bruno
Repo: usebruno/bruno PR: 6407
File: packages/bruno-app/src/components/Environments/ConfirmCloseEnvironment/index.js:5-41
Timestamp: 2025-12-17T21:41:24.730Z
Learning: Do not suggest PropTypes validation for React components in the Bruno codebase. The project does not use PropTypes, so reviews should avoid proposing PropTypes and rely on the existing typing/validation approach (e.g., TypeScript or alternative runtime checks) if applicable. This guideline applies broadly to all JavaScript/JSX components in the repo.
Applied to files:
packages/bruno-app/src/components/RequestPane/GraphQLRequestPane/index.jspackages/bruno-app/src/components/RequestPane/QueryUrl/index.js
🧬 Code graph analysis (2)
packages/bruno-app/src/components/RequestPane/GraphQLRequestPane/index.js (1)
packages/bruno-cli/src/runner/prepare-request.js (1)
get(1-1)
packages/bruno-filestore/src/formats/yml/items/parseGraphQLRequest.ts (1)
packages/bruno-converters/src/insomnia/insomnia-to-bruno.js (1)
graphql(9-9)
⏰ 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 - Linux
- GitHub Check: SSL Tests - Windows
- GitHub Check: SSL Tests - macOS
- GitHub Check: Playwright E2E Tests
- GitHub Check: CLI Tests
- GitHub Check: Unit Tests
🔇 Additional comments (3)
packages/bruno-filestore/src/formats/yml/items/parseGraphQLRequest.ts (1)
32-33: LGTM! Consistent default handling.Defaulting GraphQL query and variables to empty strings prevents null/undefined issues downstream and aligns with the frontend changes.
packages/bruno-app/src/components/RequestPane/GraphQLRequestPane/index.js (1)
48-50: LGTM! Consistent default value.The empty string default for variables aligns with the backend changes and ensures the
GraphQLVariablescomponent receives a string value.packages/bruno-app/src/components/RequestPane/QueryUrl/index.js (1)
276-276: LGTM! Robust whitespace check.The trim check properly guards against empty or whitespace-only variables before dispatching.
…uno#6453) * fix: ensure GraphQL variables are handled correctly in multiple components * fix: reverted some changes * chore: temp fix for tests --------- Co-authored-by: Bijin A B <[email protected]>
BRU-2353
Saving a GraphQL request in YAML format with an empty query body crashes the app. The YAML parser sets
querytonullwhen the field is missing, and CodeMirror'ssetValue()expects a string, causing a crash.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.