File tree Expand file tree Collapse file tree 2 files changed +26
-7
lines changed
packages/bruno-app/src/utils/codegenerator Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Original file line number Diff line number Diff line change 11import get from 'lodash/get' ;
22
33export const getAuthHeaders = ( collectionRootAuth , requestAuth ) => {
4+
5+ // Discovered edge case where code generation fails when you create a collection which has not been saved yet:
6+ // Collection auth therefore null, and request inherits from collection, therefore it is also null
7+ // TypeError: Cannot read properties of undefined (reading 'mode')
8+ // at getAuthHeaders
9+ if ( ! collectionRootAuth && ! requestAuth ) {
10+ return [ ] ;
11+ }
12+
413 const auth = collectionRootAuth && [ 'inherit' ] . includes ( requestAuth ?. mode ) ? collectionRootAuth : requestAuth ;
514
615 switch ( auth . mode ) {
Original file line number Diff line number Diff line change @@ -93,15 +93,25 @@ const createPostData = (body, type) => {
9393 ...( param . type === 'file' && { fileName : param . value } )
9494 } ) )
9595 } ;
96- case 'file' :
96+ case 'file' : {
97+ const files = Array . isArray ( body [ body . mode ] ) ? body [ body . mode ] : [ ] ;
98+ const selectedFile = files . find ( ( param ) => param . selected ) || files [ 0 ] ;
99+ const filePath = selectedFile ?. filePath || '' ;
97100 return {
98- mimeType : body [ body . mode ] . filter ( ( param ) => param . enabled ) [ 0 ] . contentType ,
99- params : body [ body . mode ]
100- . filter ( ( param ) => param . selected )
101- . map ( ( param ) => ( {
102- value : param . filePath ,
103- } ) )
101+ mimeType : selectedFile ?. contentType || 'application/octet-stream' ,
102+ text : filePath ,
103+ params : filePath
104+ ? [
105+ {
106+ name : selectedFile ?. name || 'file' ,
107+ value : filePath ,
108+ fileName : filePath ,
109+ contentType : selectedFile ?. contentType || 'application/octet-stream'
110+ }
111+ ]
112+ : [ ]
104113 } ;
114+ }
105115 default :
106116 return {
107117 mimeType : contentType ,
You can’t perform that action at this time.
0 commit comments