feat(app): open response URLs as transient requests#8189
feat(app): open response URLs as transient requests#8189jessejamesblack wants to merge 4 commits into
Conversation
WalkthroughThis PR implements clickable HTTP(S) URLs in response bodies. Clicking a URL in CodeEditor or JsonPreview response views creates and opens a transient, unsaved request with inferred method (GET or PUT for presigned URLs). The feature threads through CodeMirror link-detection, view components, and Redux request-queuing infrastructure. ChangesClickable Response URLs as Transient Requests
Sequence DiagramsequenceDiagram
participant User
participant JsonPreview
participant QueryResultPreview
participant Redux
participant TaskMiddleware
User->>JsonPreview: click URL in response body
JsonPreview->>JsonPreview: onSelect validates HTTP(S) URL
JsonPreview->>QueryResultPreview: handleResponseLinkClick(url)
QueryResultPreview->>QueryResultPreview: parse request name, infer method
QueryResultPreview->>Redux: dispatch newHttpRequest(transient config)
Redux->>TaskMiddleware: insertTaskIntoQueue with requestPaneTab
TaskMiddleware->>User: open transient request in selected pane
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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: 1
🤖 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/ResponsePane/QueryResult/QueryResultPreview/index.js`:
- Around line 96-123: handleResponseLinkClick currently accepts any URL and
creates a transient HTTP request; add a protocol gate so only http and https
links proceed. Inside handleResponseLinkClick (before calling
getRequestNameFromUrl / isPutObjectPresignedUrl and dispatching newHttpRequest),
validate the URL using the URL constructor or a simple protocol check and return
early if the protocol is not "http:" or "https:". Keep all existing behavior and
parameters (requestName via getRequestNameFromUrl, isPutObjectPresignedUrl,
getUniqueLinkedRequestFilename, newHttpRequest dispatch) unchanged when the
protocol is allowed, and show no change (or bail silently) for non-HTTP(S)
schemes.
🪄 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: 37848597-befe-40d6-9a9b-ad0a8b556eb3
📒 Files selected for processing (10)
packages/bruno-app/src/components/CodeEditor/index.jspackages/bruno-app/src/components/ResponsePane/QueryResult/QueryResultPreview/JsonPreview.jspackages/bruno-app/src/components/ResponsePane/QueryResult/QueryResultPreview/JsonPreview.spec.jspackages/bruno-app/src/components/ResponsePane/QueryResult/QueryResultPreview/index.jspackages/bruno-app/src/globalStyles.jspackages/bruno-app/src/providers/ReduxStore/middlewares/tasks/middleware.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/actions.jspackages/bruno-app/src/providers/ReduxStore/slices/collections/actions.spec.jspackages/bruno-app/src/utils/codemirror/linkAware.jspackages/bruno-app/src/utils/codemirror/linkAware.spec.js
| const handleResponseLinkClick = useCallback((url) => { | ||
| if (!url || !collection?.uid) { | ||
| return; | ||
| } | ||
|
|
||
| const requestName = getRequestNameFromUrl(url); | ||
| const isPutObject = isPutObjectPresignedUrl(url); | ||
|
|
||
| dispatch( | ||
| newHttpRequest({ | ||
| requestName, | ||
| filename: getUniqueLinkedRequestFilename(collection, requestName), | ||
| requestType: 'http-request', | ||
| requestUrl: url, | ||
| requestMethod: isPutObject ? 'PUT' : 'GET', | ||
| collectionUid: collection.uid, | ||
| itemUid: null, | ||
| isTransient: true, | ||
| auth: { | ||
| mode: 'none' | ||
| }, | ||
| settings: { | ||
| encodeUrl: false | ||
| }, | ||
| ...(isPutObject ? { requestPaneTab: 'body' } : {}) | ||
| }) | ||
| ).catch((err) => toast.error(formatIpcError(err) || 'An error occurred while adding the request')); | ||
| }, [collection, dispatch]); |
There was a problem hiding this comment.
Restrict link-click transient request creation to HTTP(S) protocols.
The shared handler accepts any URL string today; from the editor path this can open transient requests for non-HTTP schemes. Add a protocol gate here so behavior stays aligned with the HTTP(S)-only feature contract.
🔧 Proposed fix
+const isHttpUrl = (url) => {
+ try {
+ const protocol = new URL(url).protocol;
+ return protocol === 'http:' || protocol === 'https:';
+ } catch (e) {
+ return false;
+ }
+};
+
const QueryResultPreview = ({
@@
- const handleResponseLinkClick = useCallback((url) => {
- if (!url || !collection?.uid) {
+ const handleResponseLinkClick = useCallback((url) => {
+ if (!url || !collection?.uid || !isHttpUrl(url)) {
return;
}🤖 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/ResponsePane/QueryResult/QueryResultPreview/index.js`
around lines 96 - 123, handleResponseLinkClick currently accepts any URL and
creates a transient HTTP request; add a protocol gate so only http and https
links proceed. Inside handleResponseLinkClick (before calling
getRequestNameFromUrl / isPutObjectPresignedUrl and dispatching newHttpRequest),
validate the URL using the URL constructor or a simple protocol check and return
early if the protocol is not "http:" or "https:". Keep all existing behavior and
parameters (requestName via getRequestNameFromUrl, isPutObjectPresignedUrl,
getUniqueLinkedRequestFilename, newHttpRequest dispatch) unchanged when the
protocol is allowed, and show no change (or bail silently) for non-HTTP(S)
schemes.
Description
Adds support for opening URLs found in response bodies as transient, unsaved HTTP requests. This supports presigned URL workflows where an API returns a URL that should immediately be sent as a follow-up request.
For S3 presigned URLs with
x-id=PutObject, Bruno opens the transient request asPUT, disables auth, preserves URL encoding, and opens the Body tab so upload data can be configured.Closes #8188
Contribution Checklist:
Validation
npm.cmd run test --workspace=packages/bruno-app -- src/components/ResponsePane/QueryResult/QueryResultPreview/JsonPreview.spec.js src/providers/ReduxStore/slices/collections/actions.spec.js src/utils/codemirror/linkAware.spec.js --runInBandnpx.cmd eslint packages/bruno-app/src/utils/codemirror/linkAware.js packages/bruno-app/src/utils/codemirror/linkAware.spec.js packages/bruno-app/src/components/CodeEditor/index.js packages/bruno-app/src/components/ResponsePane/QueryResult/QueryResultPreview/index.js packages/bruno-app/src/components/ResponsePane/QueryResult/QueryResultPreview/JsonPreview.js packages/bruno-app/src/components/ResponsePane/QueryResult/QueryResultPreview/JsonPreview.spec.js packages/bruno-app/src/globalStyles.js packages/bruno-app/src/providers/ReduxStore/middlewares/tasks/middleware.js packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.spec.jsnpm.cmd run build:webSummary by CodeRabbit
Release Notes
New Features
Tests