{"record":{"id":"960370bcbf02a22c","repo":"usebruno/bruno","slug":"invalid-request","errorCode":"INVALID_REQUEST","errorMessage":"Missing or invalid url","messagePattern":"Missing or invalid url","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/bruno-electron/src/ipc/swagger-fetch.js","lineNumber":10,"sourceCode":"const { getCertsAndProxyConfig } = require('./network/cert-utils');\nconst { makeAxiosInstance } = require('./network/axios-instance');\n\nconst proxySwaggerFetch = async (req = {}) => {\n  const { url, method, headers, body } = req || {};\n\n  if (!url || typeof url !== 'string') {\n    return {\n      error: true,\n      code: 'INVALID_REQUEST',\n      message: 'Missing or invalid url'\n    };\n  }\n\n  try {\n    const { proxyMode, proxyConfig, httpsAgentRequestFields, interpolationOptions }\n      = await getCertsAndProxyConfig({\n        collectionUid: null,\n        collection: { promptVariables: {} },\n        request: { url },\n        envVars: {},\n        runtimeVariables: {},\n        processEnvVars: {},\n        collectionPath: '',\n        globalEnvironmentVariables: {}\n      });\n\n    const axiosInstance = makeAxiosInstance({","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/swagger-fetch.js#L1-L28","documentation":"Returned (not thrown) by proxySwaggerFetch when req.url is falsy or not a string. This is an input-validation guard at the IPC boundary: it short-circuits before any network/proxy work and returns a structured error object { error: true, code: 'INVALID_REQUEST', message } that the IPC caller is expected to inspect. Because it is a return value, try/catch will not catch it — the caller must check the .error / .code fields.","triggerScenarios":"The Electron IPC handler for swagger fetch is invoked with a req object lacking url, with url: null/undefined, or with url set to a non-string (number, object). The renderer submitted the form before the URL field was filled, or a programmatic caller forgot to set the field.","commonSituations":"User clicks 'Import from URL' with an empty URL field; a scripted caller posts an incomplete payload; a refactor stopped forwarding the url field from the renderer; URL stored as null in collection state and reused without normalization.","solutions":["Check the returned object's .error flag (and .code === 'INVALID_REQUEST') before consuming status/headers/body.","Require and validate the URL field in the renderer form before invoking the IPC handler.","Coerce/normalize url to a string and trim it client-side before sending."],"exampleFix":"// before\nconst res = await proxySwaggerFetch({ url: maybeUrl });\nif (res.status) handle(res);\n\n// after\nconst res = await proxySwaggerFetch({ url: maybeUrl });\nif (res?.error) {\n  showUserError(res.code, res.message); // 'INVALID_REQUEST', 'Missing or invalid url'\n  return;\n}\nhandle(res);","handlingStrategy":"validation","validationCode":"function hasValidUrl(req) {\n  return req != null && typeof req.url === 'string' && req.url.trim().length > 0;\n}\nif (!hasValidUrl(req)) {\n  return { error: true, code: 'INVALID_REQUEST', message: 'Missing or invalid url' };\n}\nreturn proxySwaggerFetch(req);","typeGuard":"function isSwaggerReq(v) {\n  return v != null && typeof v === 'object' && typeof v.url === 'string' && v.url.trim().length > 0;\n}\n// or, after the call (it returns errors, does not throw):\nfunction isSwaggerErrorResult(r) { return r != null && r.error === true && typeof r.code === 'string'; }","tryCatchPattern":null,"preventionTips":["proxySwaggerFetch returns errors instead of throwing — always check result.error and result.code before reading status/body.","Validate and trim the URL field in the renderer form and disable Submit until it is a non-empty string.","Centralize IPC payload validation so missing required fields never reach the handler.","Normalize url to a trimmed string before forwarding from the UI."],"tags":["validation","ipc","swagger","argument-error","electron"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}