{"record":{"id":"d0b843345525ed95","repo":"diegosouzapw/OmniRoute","slug":"invalid-image-url-must-be-a-non-empty-string","errorCode":null,"errorMessage":"Invalid image URL: must be a non-empty string","messagePattern":"Invalid image URL: must be a non-empty string","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/guardrails/visionBridgeHelpers.ts","lineNumber":288,"sourceCode":"      const dataUri = byIndex.get(imageIndex);\n      imageIndex++;\n      if (dataUri) {\n        (part as { image_url?: { url: string } }).image_url = { url: dataUri };\n      }\n    }\n  }\n  return result;\n}\n\n/**\n * Resolve image URL to data URI format for vision model.\n * - HTTP/HTTPS URLs: passed through as-is\n * - Data URIs: passed through as-is\n * - Base64 without media type: assumed PNG\n */\nexport function resolveImageAsDataUri(imageUrl: string): string {\n  if (!imageUrl || typeof imageUrl !== \"string\") {\n    throw new Error(\"Invalid image URL: must be a non-empty string\");\n  }\n\n  // Already a data URI\n  if (imageUrl.startsWith(\"data:\")) {\n    return imageUrl;\n  }\n\n  // HTTP/HTTPS URL - vision API will fetch it\n  if (imageUrl.startsWith(\"http://\") || imageUrl.startsWith(\"https://\")) {\n    return imageUrl;\n  }\n\n  // Assume it's a base64 string without prefix\n  // Add PNG as default media type\n  return `data:image/png;base64,${imageUrl}`;\n}\n\nasync function fetchRemoteImageAsDataUri(","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/guardrails/visionBridgeHelpers.ts#L270-L306","documentation":"Type/emptiness guard at the top of resolveImageAsDataUri: the imageUrl argument is falsy or not a string. The caller passed an invalid image reference (undefined/null/empty) from a normalized message part, so no URL resolution or data-URI conversion can be attempted.","triggerScenarios":"Thrown at src/lib/guardrails/visionBridgeHelpers.ts:288 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Filter empty image parts out of the message before calling the resolver","Validate the image_url.url shape with a Zod schema at the API boundary"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}