{"record":{"id":"376778a8c048a022","repo":"winstonjs/winston","slug":"cannot-make-set-from-type-other-than-array-of-stri","errorCode":null,"errorMessage":"Cannot make set from type other than Array of string elements","messagePattern":"Cannot make set from type other than Array of string elements","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/winston/transports/console.js","lineNumber":113,"sourceCode":"    }\n  }\n\n  /**\n   * Returns a Set-like object with strArray's elements as keys (each with the\n   * value true).\n   * @param {Array} strArray - Array of Set-elements as strings.\n   * @param {?string} [errMsg] - Custom error message thrown on invalid input.\n   * @returns {Object} - TODO: add return description.\n   * @private\n   */\n  _stringArrayToSet(strArray, errMsg) {\n    if (!strArray) return {};\n\n    errMsg =\n      errMsg || 'Cannot make set from type other than Array of string elements';\n\n    if (!Array.isArray(strArray)) {\n      throw new Error(errMsg);\n    }\n\n    return strArray.reduce((set, el) => {\n      if (typeof el !== 'string') {\n        throw new Error(errMsg);\n      }\n      set[el] = true;\n\n      return set;\n    }, {});\n  }\n};\n","sourceCodeStart":95,"sourceCodeEnd":126,"githubUrl":"https://github.com/winstonjs/winston/blob/ff0b79de8562bb322c390fbc82fe71c11f373428/lib/winston/transports/console.js#L95-L126","documentation":"_stringArrayToSet in the Console transport builds a lookup set from an options array (e.g. handleExceptions/level-related string arrays). It throws this Error when the value passed is not an Array at all (this occurrence, line 113). Winston throws it eagerly in the transport constructor so a misconfigured option fails fast instead of later at log time.","triggerScenarios":"new winston.transports.Console({ handleExceptions: <non-array> }) or any option routed through _stringArrayToSet given a string, object, or other non-array value instead of an array of strings (e.g. handleExceptions: 'error' instead of ['error']).","commonSituations":"Copying config from old winston v2 docs where these options had different shapes; passing a single string instead of wrapping it in an array; loading options from JSON/env where an array becomes a comma-separated string; typos like levels: 'info' passed where an array is expected.","solutions":["Pass an actual array of strings for the option, e.g. handleExceptions: ['uncaughtException'] instead of a bare string.","If the value comes from config/env, split/parse it into an array before constructing the transport.","Wrap the transport construction in try/catch and log the offending options object to identify which key is wrong."],"exampleFix":"// before\nnew winston.transports.Console({ handleExceptions: 'uncaughtException' });\n// after\nnew winston.transports.Console({ handleExceptions: ['uncaughtException'] });","handlingStrategy":"validation","validationCode":"function assertStringArray(v, name) {\n  if (!Array.isArray(v) || v.some(el => typeof el !== 'string')) {\n    throw new TypeError(`${name} must be an Array of strings`);\n  }\n}\n// assertStringArray(opts.handleExceptions, 'handleExceptions');","typeGuard":"const isStringArray = (v) => Array.isArray(v) && v.every(el => typeof el === 'string');","tryCatchPattern":"try {\n  transport = new winston.transports.Console(opts);\n} catch (err) {\n  if (err.message.includes('Cannot make set')) {\n    console.error('Bad array option in Console transport config:', opts);\n  }\n  throw err;\n}","preventionTips":["Always wrap single values in arrays: ['uncaughtException'], not 'uncaughtException'.","Validate env/JSON-derived config shapes before constructing transports.","Filter dynamic arrays with .filter(x => typeof x === 'string')."],"tags":["winston","console-transport","type-error","constructor-validation"],"backgroundTag":"invalid-option-type","analyzedSha":"ff0b79de8562bb322c390fbc82fe71c11f373428","analyzedAt":"2026-08-31T13:33:44.585Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}