NousResearch/hermes-agent · error

Missing URL

Error message

Missing URL

What it means

The cheapest guard in resourceBufferFromUrl: the rawUrl argument is falsy. The function is the shared loader behind copyImageFromUrl / saveImageFromUrl and any other resource fetch IPC — an empty/undefined URL never reaches the data:/file:/http branches.

Source

Thrown at apps/desktop/electron/main.ts:4674

    .then(value => usableTitle((value || '').slice(0, 240)))
    .then(
      async value => value || usableTitle(((await fetchHtmlTitleWithRenderer(url).catch(() => '')) || '').slice(0, 240))
    )
    .then(clean => {
      cacheTitle(key, clean)
      titleInflight.delete(key)

      return clean
    })

  titleInflight.set(key, pending)

  return pending
}

async function resourceBufferFromUrl(rawUrl) {
  if (!rawUrl) {
    throw new Error('Missing URL')
  }

  if (rawUrl.startsWith('data:')) {
    const match = rawUrl.match(/^data:([^;,]+)?(;base64)?,(.*)$/s)

    if (!match) {
      throw new Error('Invalid data URL')
    }

    const mimeType = match[1] || 'application/octet-stream'
    const encoded = match[3] || ''
    const buffer = match[2] ? Buffer.from(encoded, 'base64') : Buffer.from(decodeURIComponent(encoded), 'utf8')

    return { buffer, mimeType }
  }

  if (/^file:/i.test(rawUrl)) {
    const { resolvedPath } = await resolveReadableFileForIpc(rawUrl, { purpose: 'Image file' })

View on GitHub (pinned to c896c09c42)

Solutions

  1. Pass a non-empty URL string (data:, file:, or http(s):).
  2. In the renderer, only enable the copy/save-image menu items when an src was actually extracted from the click target.
  3. Coerce with a default or bail early: if (!url) return.

Example fix

// before
menu.items.push({ label: 'Copy image', click: () => ipc.send('copy-image', imgSrc) })

// after
if (imgSrc) {
  menu.items.push({ label: 'Copy image', click: () => ipc.send('copy-image', imgSrc) })
}
Defensive patterns

Strategy: validation

Validate before calling

function hasUrl(u) {
  return typeof u === 'string' && u.trim() !== ''
}
if (!hasUrl(rawUrl)) return // never call the IPC with an empty URL

Type guard

function isNonEmptyUrl(u) {
  return typeof u === 'string' && u.length > 0
}

Prevention

When it happens

Trigger: Renderer IPC calling copyImageFromUrl('') or saveImageFromUrl(undefined); a context-menu handler firing with no image src (e.g. the user right-clicked a non-image element and src extraction returned empty).

Common situations: Context menus enabled on containers; a URL field cleared before submit; nullish coalescing bugs upstream that turn null into ''.

Related errors


AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14). Data as JSON: /api/errors/93a5093983a3d0a8. Report an issue: GitHub.