{"record":{"id":"6b4e0a5f694e03d3","repo":"anuraghazra/github-readme-stats","slug":"could-not-render-stats-card","errorCode":null,"errorMessage":"Could not render stats card.","messagePattern":"Could not render stats card\\.","errorType":"error_code","errorClass":"CustomError","httpStatus":null,"severity":"error","filePath":"src/cards/stats.js","lineNumber":439,"sourceCode":"\n      // create the text nodes, and pass index so that we can calculate the line spacing\n      return createTextNode({\n        icon: stats.icon,\n        label: stats.label,\n        value: stats.value,\n        id: stats.id,\n        unitSymbol: stats.unitSymbol,\n        index,\n        showIcons: show_icons,\n        shiftValuePos: 79.01 + (isLongLocale ? 50 : 0),\n        bold: text_bold,\n        numberFormat: number_format,\n        numberPrecision: number_precision,\n      });\n    });\n\n  if (statItems.length === 0 && hide_rank) {\n    throw new CustomError(\n      \"Could not render stats card.\",\n      \"Either stats or rank are required.\",\n    );\n  }\n\n  // Calculate the card height depending on how many items there are\n  // but if rank circle is visible clamp the minimum height to `150`\n  let height = Math.max(\n    45 + (statItems.length + 1) * lheight,\n    hide_rank ? 0 : statItems.length ? 150 : 180,\n  );\n\n  // the lower the user's percentile the better\n  const progress = 100 - rank.percentile;\n  const cssStyles = getStyles({\n    titleColor,\n    ringColor,\n    textColor,","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/anuraghazra/github-readme-stats/blob/54a7985aeefda00d5eadb55b80c17c7f976c37d2/src/cards/stats.js#L421-L457","documentation":"Thrown by renderStatsCard when the resulting card would be completely empty: every stat item has been filtered out via the 'hide' option AND the rank circle has been disabled via hide_rank. The five always-present stat keys are stars, commits, prs, issues, and contribs, so 'hide' must contain all of them (plus any 'show'-only keys) for statItems.length to reach 0. The library refuses to render a blank SVG and surfaces this CustomError with the secondary message 'Either stats or rank are required.'","triggerScenarios":"A GET /api/?username=X request that combines hide_rank=true with a hide query param listing every stat key, e.g. hide=stars,commits,prs,issues,contribs. Because the always-on keys are exactly {stars,commits,prs,issues,contribs}, hiding all five (and any extras surfaced via 'show') empties statItems; together with hide_rank=true the guard at stats.js:438 trips.","commonSituations":"A user copying a 'minimal card' snippet that hides stats to get a rank-only card, then separately toggling hide_rank=true; or a user iterating on hide= values until nothing remains. Also seen when a template sets hide='*' style lists without realizing rank is also disabled.","solutions":["Remove at least one stat from the hide list so statItems is non-empty (e.g. drop 'contribs' from hide).","If you want a rank-only card, keep hide_rank=false (or omit it) and hide the stats instead — the rank circle alone renders fine.","If you want a stats-only card, keep hide_rank=true but leave at least one of stars/commits/prs/issues/contribs visible."],"exampleFix":"// before\n// /api/?username=X&hide=stars,commits,prs,issues,contribs&hide_rank=true\n\n// after (rank-only card is legal; just don't also hide rank)\n// /api/?username=X&hide=stars,commits,prs,issues,contribs\n// or keep at least one stat:\n// /api/?username=X&hide=stars,commits,prs,issues&hide_rank=true","handlingStrategy":"validation","validationCode":"// Validate render options before calling renderStatsCard.\nconst ALWAYS_ON_STATS = [\"stars\", \"commits\", \"prs\", \"issues\", \"contribs\"];\nfunction validateStatsCardOptions({ hide = [], hide_rank = false, show = [] }) {\n  const hideSet = new Set(hide);\n  const visible = ALWAYS_ON_STATS.filter((k) => !hideSet.has(k));\n  if (visible.length === 0 && hide_rank) {\n    throw new Error(\n      \"Refusing to render an empty card: keep at least one stat, or set hide_rank=false for a rank-only card.\",\n    );\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When building hide lists programmatically, intersect with ALWAYS_ON_STATS and assert the remainder is non-empty unless hide_rank is false.","Treat a rank-only card (hide_rank=false + all stats hidden) as the intentional 'minimal' shape, not hide_rank=true + all stats hidden.","Unit-test the options combinator: every combination of hide + hide_rank must either render or throw a deliberate error."],"tags":["stats-card","configuration","render-options","validation"],"backgroundTag":null,"analyzedSha":"54a7985aeefda00d5eadb55b80c17c7f976c37d2","analyzedAt":"2026-08-12T23:20:41.776Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}