{"record":{"id":"b33dc7e2d44e9fe1","repo":"balderdashy/sails","slug":"rc-name-name-must-be-string","errorCode":null,"errorMessage":"rc(name): name *must* be string","messagePattern":"rc\\(name\\): name \\*must\\* be string","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/util/rc.js","lineNumber":152,"sourceCode":"\n    function find(start, rel) {\n      var file = path.join(start, rel);\n      try {\n        fs.statSync(file);\n        return file;\n      } catch (unusedErr) {\n        if(path.dirname(start) !== start) {// root\n          return find(path.dirname(start), rel);\n        }\n      }\n    }\n    return find(process.cwd(), rel);\n  };\n\n\n\n  if('string' !== typeof name) {\n    throw new Error('rc(name): name *must* be string');\n  }\n  if(!argv) {\n    argv = require('minimist')(process.argv.slice(2));\n  }\n  defaults = (\n      'string' === typeof defaults\n    ? jsonFn(defaults) : defaults\n  ) || {};\n\n  parse = parse || parseFn;\n\n  var env = envFn(name + '_');\n\n  var configs = [defaults];\n  var configFiles = [];\n  function addConfigFile (file) {\n    if (configFiles.indexOf(file) >= 0) {return;}\n    var fileConfig = fileFn(file);","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/balderdashy/sails/blob/7b76422cc27823df033572bdda5c4910a68b697f/lib/util/rc.js#L134-L170","documentation":"The `rc` utility used to load Sails configuration requires its first argument, the app name, to be a string. Passing a non-string (undefined, object, number) to rc(name) throws this error immediately.","triggerScenarios":"Calling rc(name) with `name` undefined, null, a number, or an object; programmatically loading Sails config with `require('sails').load()`-style helpers that pass a bad name; calling the rc module directly with missing args.","commonSituations":"Custom config loaders wiring rc() incorrectly; calling rc() with arguments in the wrong order; forgetting the app name parameter entirely.","solutions":["Pass a non-empty string as the first argument, e.g. `rc('sails', { ... })`.","Check argument order when calling rc; the name must come before defaults/argv.","If name comes from variables, validate with typeof name === 'string' before calling.","Use require('rc') from the same version Sails expects to avoid signature drift."],"exampleFix":"// before\nvar config = rc();\n// after\nvar config = rc('sails');","handlingStrategy":"type-guard","validationCode":"if (typeof name !== 'string' || !name.length) { throw new TypeError('rc(name): name must be a non-empty string'); }","typeGuard":"function isRcName(v) { return typeof v === 'string' && v.length > 0; }","tryCatchPattern":"try { config = rc(name); } catch (e) { if (/name \\*must\\* be string/.test(e.message)) { config = rc('sails'); } else { throw e; } }","preventionTips":["Always pass a literal app-name string as rc's first argument.","Validate variables used as name before the call.","Keep argument order: name, defaults, then argv.","Add unit tests for config-loading helpers."],"tags":["sails","rc","configuration","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"7b76422cc27823df033572bdda5c4910a68b697f","analyzedAt":"2026-09-01T04:01:57.104Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}