{"record":{"id":"6691b2c1c58fb566","repo":"feathericons/feather","slug":"the-required-key-icon-name-parameter-is-missin","errorCode":null,"errorMessage":"The required `key` (icon name) parameter is missing.","messagePattern":"The required `key` \\(icon name\\) parameter is missing\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/to-svg.js","lineNumber":16,"sourceCode":"import icons from './icons';\n\n/**\n * Create an SVG string.\n * @deprecated\n * @param {string} name\n * @param {Object} attrs\n * @returns {string}\n */\nfunction toSvg(name, attrs = {}) {\n  console.warn(\n    'feather.toSvg() is deprecated. Please use feather.icons[name].toSvg() instead.',\n  );\n\n  if (!name) {\n    throw new Error('The required `key` (icon name) parameter is missing.');\n  }\n\n  if (!icons[name]) {\n    throw new Error(\n      `No icon matching '${name}'. See the complete list of icons at https://feathericons.com`,\n    );\n  }\n\n  return icons[name].toSvg(attrs);\n}\n\nexport default toSvg;\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/feathericons/feather/blob/3dc050d97405062eba78aa57115c0a15c63abdaa/src/to-svg.js#L1-L29","documentation":"feather.toSvg(name, attrs) (deprecated) requires an icon name string as its first argument; it is used to look up the icon in the internal icons map. When the argument is undefined, null, or an empty string, the library cannot proceed and throws. The method is deprecated in favor of feather.icons[name].toSvg().","triggerScenarios":"Calling feather.toSvg() with no arguments, or with a variable that is undefined/null/'' at call time (e.g. a failed config lookup or a missing prop).","commonSituations":"Passing a dynamically computed icon name that ends up empty; a component prop with no default; migration code calling the old API with an unset variable.","solutions":["Pass a non-empty icon name string: feather.toSvg('circle').","Better, migrate to the non-deprecated API: feather.icons[name].toSvg(attrs).","Add a default value for the variable/prop that supplies the name.","Validate typeof name === 'string' && name before calling."],"exampleFix":"// before\nfeather.toSvg(iconName); // iconName is undefined\n\n// after\nfeather.icons['circle'].toSvg();","handlingStrategy":"validation","validationCode":"if (typeof name !== 'string' || name.length === 0) throw new Error('icon name is required');","typeGuard":"const hasIconName = (v: unknown): v is string => typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":"try {\n  const svg = feather.icons[name].toSvg(attrs);\n} catch (e) {\n  if (e.message.includes('required `key`')) {\n    // fall back to a default icon or surface a config error\n  } else {\n    throw e;\n  }\n}","preventionTips":["Provide default values for props/vars that supply icon names","Migrate from feather.toSvg() to feather.icons[name].toSvg()","Validate icon name inputs at configuration boundaries"],"tags":["missing-argument","deprecated-api","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"3dc050d97405062eba78aa57115c0a15c63abdaa","analyzedAt":"2026-08-30T12:01:49.665Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}