{"record":{"id":"a448447d927b96ee","repo":"quasarframework/quasar","slug":"expected-a-string-or-a-r-g-b-a-object-as-fg","errorCode":null,"errorMessage":"Expected a string or a {r, g, b[, a]} object as fgColor","messagePattern":"Expected a string or a (.+?) object as fgColor","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ui/src/utils/colors/colors.js","lineNumber":231,"sourceCode":"    R = r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4,\n    G = g <= 0.03928 ? g / 12.92 : ((g + 0.055) / 1.055) ** 2.4,\n    B = b <= 0.03928 ? b / 12.92 : ((b + 0.055) / 1.055) ** 2.4\n  return 0.2126 * R + 0.7152 * G + 0.0722 * B\n}\n\nexport function brightness(color) {\n  if (typeof color !== 'string' && (!color || color.r === void 0)) {\n    throw new TypeError('Expected a string or a {r, g, b} object as color')\n  }\n\n  const rgb = typeof color === 'string' ? textToRgb(color) : color\n\n  return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000\n}\n\nexport function blend(fgColor, bgColor) {\n  if (typeof fgColor !== 'string' && (!fgColor || fgColor.r === void 0)) {\n    throw new TypeError(\n      'Expected a string or a {r, g, b[, a]} object as fgColor'\n    )\n  }\n\n  if (typeof bgColor !== 'string' && (!bgColor || bgColor.r === void 0)) {\n    throw new TypeError(\n      'Expected a string or a {r, g, b[, a]} object as bgColor'\n    )\n  }\n\n  const rgb1 = typeof fgColor === 'string' ? textToRgb(fgColor) : fgColor,\n    r1 = rgb1.r / 255,\n    g1 = rgb1.g / 255,\n    b1 = rgb1.b / 255,\n    a1 = rgb1.a !== void 0 ? rgb1.a / 100 : 1,\n    rgb2 = typeof bgColor === 'string' ? textToRgb(bgColor) : bgColor,\n    r2 = rgb2.r / 255,\n    g2 = rgb2.g / 255,","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/quasarframework/quasar/blob/4841521b5f635a971eb9e2710e5542efd194691b/ui/src/utils/colors/colors.js#L213-L249","documentation":"Quasar's blend(fgColor, bgColor) alpha-blends two colors. Both arguments must be a color string or an {r,g,b[,a]} object; a foreground that is neither (null, undefined, number, object without r) throws this TypeError before the background is even validated.","triggerScenarios":"blend(undefined, '#fff'), blend(123, '#000'), blend({}, '#000'), or the changeAlpha/getPaletteColor pipeline feeding an unresolved color into blend.","commonSituations":"Overlay/tint colors read from config that isn't loaded; passing textToRgb output mixed with a raw hex inconsistently across branches; typos in computed color objects (missing r).","solutions":["Pass strings for both: blend('#80808040', '#ffffff')","Validate that fgColor is a string or has r defined before calling","Resolve palette/config colors (getPaletteColor) before blending","Provide fallback constants for config-driven colors so they can never be undefined"],"exampleFix":"// before\nreturn blend(fgFromConfig, bgColor) // fgFromConfig undefined\n// after\nreturn blend(fgFromConfig ?? 'rgba(0,0,0,0.25)', bgColor)","handlingStrategy":"type-guard","validationCode":"function canBlend(fg, bg) {\n  const ok = c => typeof c === 'string' || (c !== null && c !== void 0 && c.r !== void 0)\n  return ok(fg) && ok(bg)\n}\nif (canBlend(fgColor, bgColor)) blend(fgColor, bgColor)","typeGuard":"function isBlendableColor(v) {\n  return typeof v === 'string' || (v !== null && typeof v === 'object' && v.r !== void 0)\n}","tryCatchPattern":"try {\n  out = blend(fg, bg)\n} catch (err) {\n  if (err.message.includes('as fgColor')) {\n    out = blend('rgba(0,0,0,0.25)', bg) // default overlay\n  } else if (err.message.includes('as bgColor')) {\n    out = blend(fg, '#ffffff')\n  } else {\n    throw err\n  }\n}","preventionTips":["Give overlay/tint config values concrete defaults","Resolve palette names to hex strings before blending","Never blend with undefined during first render — gate on loaded state","Keep both arguments the same form (strings) to avoid mixed-shape bugs"],"tags":["colors","type-mismatch","typeerror"],"backgroundTag":"invalid-argument-type","analyzedSha":"4841521b5f635a971eb9e2710e5542efd194691b","analyzedAt":"2026-08-30T01:13:14.944Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}