moeru-ai/airi · error · Error

Output does not contain a recognizable image URL.

Error message

Output does not contain a recognizable image URL.

What it means

Thrown after iterating the output items when the first element is an object that lacks a callable `url`, is not a string, and does not match any of the three recognized shapes (FileUpload with .url(), object with .url string, or raw URL string). The extracted imageUrl is undefined or does not start with http/data:.

Source

Thrown at apps/stage-tamagotchi/src/main/services/airi/widgets/providers/replicate.ts:167

        if (typeof first === 'object' && first !== null && 'url' in first && typeof (first as any).url === 'function') {
          imageUrl = (first as any).url().href
        }
        // Case 2: Object with url property as a string
        else if (typeof first === 'object' && first !== null && 'url' in first && typeof (first as any).url === 'string') {
          imageUrl = (first as any).url
        }
        // Case 3: Simple string (the URL itself)
        else if (typeof first === 'string') {
          imageUrl = first
        }

        if (imageUrl && (imageUrl.startsWith('http') || imageUrl.startsWith('data:'))) {
          log.log(`[Replicate] EXTRACTED IMAGE: ${imageUrl.startsWith('data:') ? 'DATA_URL' : imageUrl}`)
          this.updateStatus(jobId, { status: 'succeeded', progress: 100, imageUrl })
        }
        else {
          log.error(`[Replicate] Failed to extract URL from output: ${JSON.stringify(first)}`)
          throw new Error('Output does not contain a recognizable image URL.')
        }
      }
      else {
        throw new Error('Replicate returned an empty output array.')
      }
    }
    catch (error: any) {
      const errorMessage = error.message || (typeof error === 'object' ? JSON.stringify(error) : String(error))
      log.error(`[Replicate] Generation Failed for ${jobId}: ${errorMessage}`)
      this.updateStatus(jobId, {
        status: 'failed',
        error: errorMessage,
        actionLabel: `Error: ${errorMessage.slice(0, 50)}${errorMessage.length > 50 ? '...' : ''}`,
      })
    }
    finally {
      // Clean up callback and job result after completion to prevent memory leaks
      setTimeout(() => {

View on GitHub (pinned to 27111382b4)

Solutions

  1. Inspect the logged `[Replicate] Failed to extract URL from output:` line to see the actual object shape, then add a matching extraction branch.
  2. Pin or upgrade the replicate npm package deliberately and re-test; the SDK output contract changed across major versions.
  3. Verify the model is an image-output model (flux, sd-xl, etc.), not a generic model.
  4. Add a branch for `first.output` or `first.url` as a string property in addition to the callable check.

Example fix

// before
if (typeof first === 'object' && first !== null && 'url' in first && typeof (first as any).url === 'function') {
  imageUrl = await (first as any).url()
}

// after
if (typeof first === 'object' && first !== null) {
  if (typeof (first as any).url === 'function') imageUrl = await (first as any).url()
  else if (typeof (first as any).url === 'string') imageUrl = (first as any).url
  else if (typeof (first as any).output === 'string') imageUrl = (first as any).output
}
Defensive patterns

Strategy: try-catch

Type guard

function isFileUploadWithUrl(item: unknown): boolean {
  return typeof item === 'object' && item !== null
    && 'url' in item
    && (typeof (item as any).url === 'function' || typeof (item as any).url === 'string')
}
function isUrlString(item: unknown): item is string {
  return typeof item === 'string' && /^https?:|^data:/.test(item)
}

Try / catch

try {
  // extraction logic
} catch (e) {
  log.error('Replicate output shape unrecognized', { first })
  throw e
}

Prevention

When it happens

Trigger: Replicate SDK upgraded to a version that returns a new output envelope shape (e.g. a PaginatedResponse, a different FileUpload API, or a prediction object instead of bare outputs); model returns a metadata object instead of an image reference.

Common situations: replicate npm package version bump changed run() return shape; model returns output as an object with a nested URL under a non-standard key; the model is not an image model and returns text/JSON.

Related errors


AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12). Data as JSON: /api/errors/5514e1b3d50c167f. Report an issue: GitHub.