{
  "id": "api/graphql-non-null-field-returned-null",
  "signature": "GraphQL error: Cannot return null for non-nullable field",
  "signature_zh": "GraphQL 错误：不能为非空字段返回 null",
  "regex": "Cannot\\s+return\\s+null\\s+for\\s+non-nullable\\s+field",
  "domain": "api",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "A resolver returned null for a field marked as non-nullable (!) in the GraphQL schema, causing the parent field to also become null (null propagation).",
  "root_cause_type": "generic",
  "root_cause_zh": "解析器为 GraphQL 模式中标记为非空 (!) 的字段返回了 null，导致父字段也变为 null（null 传播）。",
  "versions": [
    {
      "version": "graphql-js 16.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Apollo Server 4.9.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "GraphQL Ruby 2.3.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "HotChocolate 13.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Clients may not handle null gracefully, leading to runtime errors or missing data.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Default values can hide data integrity problems and produce incorrect results.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Returning null from a non-null field still triggers the same error, as GraphQL validates at the schema level.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Identify the failing field from the error path (e.g., 'user.profile.name') and fix the resolver to return a valid value. Example: ensure the database query joins the required table or adds a fallback like `name: user.name || 'Unknown'`.",
      "success_rate": 0.9,
      "how": "Identify the failing field from the error path (e.g., 'user.profile.name') and fix the resolver to return a valid value. Example: ensure the database query joins the required table or adds a fallback like `name: user.name || 'Unknown'`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Temporarily make the field nullable in the schema (change `!` to `?` in SDL) to prevent null propagation while debugging the resolver.",
      "success_rate": 0.75,
      "how": "Temporarily make the field nullable in the schema (change `!` to `?` in SDL) to prevent null propagation while debugging the resolver.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add error handling in the resolver to log the null case and return a sensible default. For example, in JavaScript: `const name = user?.profile?.name ?? 'Anonymous';`.",
      "success_rate": 0.85,
      "how": "Add error handling in the resolver to log the null case and return a sensible default. For example, in JavaScript: `const name = user?.profile?.name ?? 'Anonymous';`.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Identify the failing field from the error path (e.g., 'user.profile.name') and fix the resolver to return a valid value. Example: ensure the database query joins the required table or adds a fallback like `name: user.name || 'Unknown'`.",
    "Temporarily make the field nullable in the schema (change `!` to `?` in SDL) to prevent null propagation while debugging the resolver.",
    "Add error handling in the resolver to log the null case and return a sensible default. For example, in JavaScript: `const name = user?.profile?.name ?? 'Anonymous';`."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://graphql.org/learn/schema/#non-null",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.82,
  "resolvable": "partial",
  "first_seen": "2023-09-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2025-01-30",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}