{"record":{"id":"da2be3b81fb84e27","repo":"gatsbyjs/gatsby","slug":"message-context-sourcemessage","errorCode":null,"errorMessage":"message?.context?.sourceMessage","messagePattern":"message\\?\\.context\\?\\.sourceMessage","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby-source-wordpress/src/utils/fetch-graphql.ts","lineNumber":719,"sourceCode":"  throwGqlErrors = false,\n  throwFetchErrors = false,\n  url,\n  variables = {},\n  headers = {},\n  errorContext = null,\n  isFirstRequest = false,\n  forceReportCriticalErrors = false,\n}: IFetchGraphQLInput): Promise<IGraphQLDataResponse> => {\n  const { helpers, pluginOptions } = getStore().getState().gatsbyApi\n  const limit = pluginOptions?.schema?.requestConcurrency\n\n  const { url: pluginOptionsUrl } = pluginOptions\n  let { reporter } = helpers\n\n  if (!reporter || typeof reporter === `undefined`) {\n    reporter = {\n      panic: (message: { id: string; context: { sourceMessage: string } }) => {\n        throw new Error(message?.context?.sourceMessage)\n      },\n      error: console.error as GatsbyReporter[\"error\"],\n    } as GatsbyReporter\n  }\n\n  if (!url) {\n    url = pluginOptionsUrl\n  }\n\n  const timeout = pluginOptions.schema.timeout\n\n  const htaccessCredentials = pluginOptions.auth.htaccess\n\n  const missingCredentials =\n    !htaccessCredentials.password || !htaccessCredentials.username\n\n  let response: AxiosResponse\n","sourceCodeStart":701,"sourceCodeEnd":737,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-source-wordpress/src/utils/fetch-graphql.ts#L701-L737","documentation":"When the Gatsby reporter is missing (e.g. running fetch-graphql outside a full Gatsby runtime), gatsby-source-wordpress installs a stub reporter whose panic() rethrows message.context.sourceMessage as a plain Error. So the visible message is whatever upstream code passed as the structured panic payload's sourceMessage. This is a fallback path: in normal builds the real reporter handles the panic instead.","triggerScenarios":"Calling fetch-graphql in isolation (tests, scripts) where helpers.reporter is undefined; an internal code path that constructs a panic with a malformed context object (missing sourceMessage); a regression where the stub reporter is hit during normal builds.","commonSituations":"Unit tests for gatsby-source-wordpress that mock the store without a reporter; running pieces of the plugin outside gatsby; a bug causing helpers.reporter to be undefined during a real build.","solutions":["If you see this in a real build, upgrade gatsby-source-wordpress — helpers.reporter should always be present.","In tests, provide a stub reporter with panic/error methods so the real path is exercised.","Inspect the panic payload (id and context.sourceMessage) to find which subsystem raised it.","Confirm the Gatsby version provides reporter on helpers at the lifecycle being used."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"if (!helpers.reporter || typeof helpers.reporter === 'undefined') { throw new Error('Gatsby reporter missing; running fetch-graphql outside Gatsby?') }","typeGuard":"const hasReporter = (h) => h && typeof h.reporter?.panic === 'function'","tryCatchPattern":"try { await fetchGraphQL(opts) } catch (e) { if (/context/.test(e.message)) { reporter.error('Stub reporter was used; sourceMessage: ' + e.message) } throw e }","preventionTips":["Always provide a real reporter when invoking fetch-graphql in tests","Upgrade gatsby-source-wordpress if this fires during real builds","Validate that helpers.reporter is present before entering the GraphQL step"],"tags":["wordpress","reporter","runtime"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}