{"record":{"id":"e536747568e3b1b6","repo":"hexojs/hexo","slug":"invalid-config-detected-url-should-be-string-n","errorCode":null,"errorMessage":"Invalid config detected: \"url\" should be string, not ${typeof config.url}!","messagePattern":"Invalid config detected: \"url\" should be string, not (.+?)!","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"critical","filePath":"lib/hexo/validate_config.ts","lineNumber":12,"sourceCode":"import assert from 'assert';\nimport moment from 'moment-timezone';\nimport type Hexo from './index';\n\nexport = (ctx: Hexo): void => {\n  const { config, log } = ctx;\n\n  log.info('Validating config');\n\n  // Validation for config.url && config.root\n  if (typeof config.url !== 'string') {\n    throw new TypeError(`Invalid config detected: \"url\" should be string, not ${typeof config.url}!`);\n  }\n  try {\n    // eslint-disable-next-line no-new\n    new URL(config.url);\n    assert(new URL(config.url).protocol.startsWith('http'));\n  } catch {\n    throw new TypeError('Invalid config detected: \"url\" should be a valid URL!');\n  }\n\n  if (typeof config.root !== 'string') {\n    throw new TypeError(`Invalid config detected: \"root\" should be string, not ${typeof config.root}!`);\n  }\n  if (config.root.trim().length <= 0) {\n    throw new TypeError('Invalid config detected: \"root\" should not be empty!');\n  }\n\n  if (!config.timezone) {\n    log.warn('No timezone setting detected! Using LocalTimeZone as the default timezone.');","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/hexojs/hexo/blob/059cb17494d0632a053c24077f5bcb6ae92acc51/lib/hexo/validate_config.ts#L1-L30","documentation":"Thrown by validate_config (lib/hexo/validate_config.ts:12) during Hexo startup. The url field in _config.yml must be a string. This check runs before URL parsing, so a non-string url (number, object, array, null after YAML quirks) is rejected with the actual type interpolated.","triggerScenarios":"config.url is not a string: e.g. url: 123, url: [http://x], url: { href: ... } in _config.yml, or url omitted and defaulted to undefined. The validator runs on every hexo generate/server/launch.","commonSituations":"YAML parsing a bare number or colon-less token into a non-string; a theme/plugin overwriting config.url with an object; migrating a config and leaving url blank; environment-specific config override injecting a non-string.","solutions":["Open _config.yml and set url to a quoted http(s) string: url: https://example.com.","If url is provided elsewhere (e.g. _config.<env>.yml or a plugin), ensure that source also yields a string.","Search the codebase for assignments to config.url and fix any that set a non-string.","Restart hexo after saving the config."],"exampleFix":"# before (_config.yml)\nurl: 123\n\n# after\nurl: https://example.com","handlingStrategy":"validation","validationCode":"const url = hexo.config.url;\nif (typeof url !== 'string') {\n  throw new Error(`_config.yml 'url' must be a string, got ${typeof url}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always quote url in _config.yml: url: 'https://example.com'.","Run a config lint at CI startup that asserts typeof config.url === 'string'.","Audit plugins/themes that mutate config.url."],"tags":["config","validation","startup","url"],"backgroundTag":null,"analyzedSha":"059cb17494d0632a053c24077f5bcb6ae92acc51","analyzedAt":"2026-08-12T20:52:05.731Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}