{"record":{"id":"dfbffb14f64b0eea","repo":"toeverything/AFFiNE","slug":"empty-graphql-error-body","errorCode":null,"errorMessage":"Empty GraphQL error body","messagePattern":"Empty GraphQL error body","errorType":"exception","errorClass":"GraphQLError","httpStatus":null,"severity":"error","filePath":"packages/common/graphql/src/fetcher.ts","lineNumber":225,"sourceCode":"    const ret = fetcher(\n      endpoint,\n      merge(options.context, {\n        method: 'POST',\n        headers,\n        body: isFormData ? body : JSON.stringify(body),\n        timeout: options.timeout,\n        signal: options.signal,\n      })\n    ).then(async res => {\n      if (res.headers.get('content-type')?.startsWith('application/json')) {\n        const result = (await res.json()) as ExecutionResult;\n        if (res.status >= 400 || result.errors) {\n          if (result.errors && result.errors.length > 0) {\n            // throw the first error is enough\n            const firstError = result.errors[0];\n            throw new GraphQLError(firstError.message, firstError);\n          } else {\n            throw new GraphQLError('Empty GraphQL error body');\n          }\n        } else if (result.data) {\n          // we have to cast here because the type of result.data is a union type\n          return result.data as any;\n        }\n      }\n\n      throw new GraphQLError(\n        'GraphQL query responds unexpected result, query ' + options.query.op\n      );\n    });\n\n    return ret;\n  };\n\n  return gqlFetch;\n};\n","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/common/graphql/src/fetcher.ts#L207-L243","documentation":"In gqlFetch, when the response has HTTP status >= 400 (or errors) but the JSON body contains no `errors` array, there is nothing meaningful to surface, so an Error('Empty GraphQL error body') is thrown to avoid swallowing the failure.","triggerScenarios":"Thrown at packages/common/graphql/src/fetcher.ts:225 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check network connectivity to the GraphQL endpoint; the error response body was empty.","Retry the request; transient proxy or server failures can produce empty error bodies.","Inspect server and proxy logs for the corresponding failed request."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}