gatsbyjs/gatsby · error
Failed to process search and replace string in ${node.__type
Error message
Failed to process search and replace string in ${node.__typename} ${node.id} What it means
Warns that a searchAndReplace entry from plugin options failed when applied to the node's serialized string. The search pattern is compiled as a RegExp and the replacement run inside try/catch; a malformed regex or invalid replacement pattern makes it throw, and the node keeps its unmodified string.
Source
Thrown at packages/gatsby-source-wordpress/src/steps/source-nodes/create-nodes/process-node.js:913
export const searchAndReplaceNodeStrings = ({
nodeString,
node,
pluginOptions,
}) => {
if (Array.isArray(pluginOptions?.searchAndReplace)) {
pluginOptions.searchAndReplace.forEach(({ search, replace }) => {
const searchRegex = new RegExp(search, `g`)
const stringMatches = execall(searchRegex, nodeString)
if (stringMatches.length) {
stringMatches.forEach(({ match }) => {
if (match) {
try {
nodeString = nodeString.replace(search, replace)
} catch (e) {
console.error(e)
console.warn(
formatLogMessage(
`Failed to process search and replace string in ${node.__typename} ${node.id}`
)
)
}
}
})
}
})
}
return nodeString
}
const processNodeString = async ({
nodeString,
node,
pluginOptions,View on GitHub (pinned to e85d62f177)
Solutions
- Fix the invalid entries in pluginOptions.searchAndReplace (bad regex in the `search` string)
- Test each `search` value with new RegExp() before configuring it
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/gatsby-source-wordpress/src/steps/source-nodes/create-nodes/process-node.js:913 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/e992f47cae26c5e0.
Report an issue: GitHub.