gatsbyjs/gatsby · error

Couldn't find source url for media item #${databaseId}

Error message

Couldn't find source url for media item #${databaseId}

What it means

Data-quality guard when looking up an existing local file node for a media item: neither sourceUrl nor mediaItemUrl is present on the media item node, so there is no URL to key the lookup on. The helper warns (via formatLogMessage) and returns null, which typically triggers a fresh fetch/creation path for that media item.

Source

Thrown at packages/gatsby-source-wordpress/src/steps/source-nodes/create-nodes/create-local-file-node.js:163

      )
    )
    reporter.panic(error)
  } else {
    console.error(error)
    reporter.panic()
  }
}

export const getFileNodeByMediaItemNode = async ({
  mediaItemNode,
  helpers,
}) => {
  const { sourceUrl, modifiedGmt, mediaItemUrl, databaseId } = mediaItemNode

  const fileUrl = sourceUrl || mediaItemUrl

  if (!fileUrl) {
    helpers.reporter.warn(
      formatLogMessage(`Couldn't find source url for media item #${databaseId}`)
    )
    return null
  }

  const existingNodeMeta = getFileNodeMetaBySourceUrl(fileUrl)

  if (
    // if we already have this image
    existingNodeMeta &&
    existingNodeMeta.id &&
    // and it hasn't been modified
    existingNodeMeta.modifiedGmt === modifiedGmt
  ) {
    let node = await helpers.getNode(existingNodeMeta.id)

    // some of the cached node metas don't necessarily need to be a File
    // so make sure we return a File node if what we get isn't one

View on GitHub (pinned to e85d62f177)

Solutions

  1. Inspect the media item node in GraphiQL to confirm which URL fields are populated
  2. Re-sync media: run `gatsby clean` and re-develop so the media item is re-fetched with full fields
  3. Check WPGraphQL permissions — private/unpublished media may omit URL fields for the configured auth user
  4. If persistent, exclude the problematic content type or fix the upstream WordPress data
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/gatsby-source-wordpress/src/steps/source-nodes/create-nodes/create-local-file-node.js:163 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gatsbyjs/gatsby@e85d62f177 (2026-08-26). Data as JSON: /api/errors/af49f5e93af77acd. Report an issue: GitHub.