{"record":{"id":"358af83dfad14a2c","repo":"vercel/ai","slug":"description-setting-must-be-a-string","errorCode":null,"errorMessage":"${description} setting must be a string.","messagePattern":"(.+?) setting must be a string\\.","errorType":"exception","errorClass":"LoadSettingError","httpStatus":null,"severity":"error","filePath":"packages/provider-utils/src/load-setting.ts","lineNumber":28,"sourceCode":" * @returns The setting value.\n */\nexport function loadSetting({\n  settingValue,\n  environmentVariableName,\n  settingName,\n  description,\n}: {\n  settingValue: string | undefined;\n  environmentVariableName: string;\n  settingName: string;\n  description: string;\n}): string {\n  if (typeof settingValue === 'string') {\n    return settingValue;\n  }\n\n  if (settingValue != null) {\n    throw new LoadSettingError({\n      message: `${description} setting must be a string.`,\n    });\n  }\n\n  if (typeof process === 'undefined') {\n    throw new LoadSettingError({\n      message:\n        `${description} setting is missing. ` +\n        `Pass it using the '${settingName}' parameter. ` +\n        `Environment variables are not supported in this environment.`,\n    });\n  }\n\n  settingValue = process.env[environmentVariableName];\n\n  if (settingValue == null) {\n    throw new LoadSettingError({\n      message:","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/provider-utils/src/load-setting.ts#L10-L46","documentation":"loadSetting validates a provider setting (e.g. region, fetch function) resolved from options or environment. If a value was supplied that is neither a string nor null/undefined, it throws LoadSettingError with this message, preventing invalid setting types from reaching the provider internals.","triggerScenarios":"Passing a non-string, non-nullish value for a setting like region: createAmazonBedrock({ region: 123 }) or { fetch: 'notAFunction' }-style wrong-typed options handled by loadSetting.","commonSituations":"Config files or CLI parsers yielding numbers/booleans; copy-paste mistakes passing a settings object instead of a string; template literals accidentally wrapping objects.","solutions":["Pass the setting as a string (e.g. region: 'us-east-1')","Coerce or validate config-derived values before constructing the provider","Check provider docs for the option's expected type and allowed values","If the value may be absent, pass undefined rather than a wrong-typed placeholder so env fallback applies"],"exampleFix":"// before\nconst bedrock = createAmazonBedrock({ region: 123 });\n// after\nconst bedrock = createAmazonBedrock({ region: 'us-east-1' });","handlingStrategy":"validation","validationCode":"const region = cfg.region;\nif (region != null && typeof region !== 'string') throw new Error('region must be a string, got ' + typeof region);\nconst bedrock = createAmazonBedrock({ region });","typeGuard":"function isSettingString(value: unknown): value is string {\n  return typeof value === 'string';\n}","tryCatchPattern":"try {\n  const bedrock = createAmazonBedrock({ region: config.region });\n} catch (error) {\n  if (/setting must be a string/.test(String(error.message))) {\n    throw new Error('Config error: region must be a string');\n  }\n  throw error;\n}","preventionTips":["Type provider option objects strictly so non-strings are rejected at compile time","Validate config files with a schema (zod) before passing to provider factories","Pass undefined (not a wrong-typed placeholder) when a setting is absent"],"tags":["configuration","validation","settings"],"backgroundTag":"invalid-config-value","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}