{"record":{"id":"e2c98148a8c6c61c","repo":"nexu-io/open-design","slug":"input-fields-must-be-an-array-of-strings","errorCode":null,"errorMessage":"input.fields must be an array of strings","messagePattern":"input\\.fields must be an array of strings","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/live-artifacts/refresh.ts","lineNumber":675,"sourceCode":"    throw new Error('public_github_repository_metric input.url must be a valid URL');\n  }\n\n  if (url.protocol !== 'https:' || url.hostname !== 'api.github.com') {\n    throw new Error('public_github_repository_metric only supports https://api.github.com repository URLs');\n  }\n  if (!/^\\/repos\\/[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/.test(url.pathname)) {\n    throw new Error('public_github_repository_metric only supports /repos/{owner}/{repo} URLs');\n  }\n  url.search = '';\n  url.hash = '';\n  url.username = '';\n  url.password = '';\n  return url;\n}\n\nfunction selectGithubFields(input: PublicGithubRepositoryMetricInput): string[] {\n  if (input.fields === undefined) return ['stargazers_count', 'full_name', 'html_url', 'updated_at'];\n  if (!Array.isArray(input.fields)) throw new Error('input.fields must be an array of strings');\n  const fields = input.fields.filter((field): field is string => typeof field === 'string');\n  if (fields.length !== input.fields.length) throw new Error('input.fields must be an array of strings');\n  return fields.slice(0, 20);\n}\n\nasync function executePublicGithubRepositoryMetric(options: ExecuteLocalDaemonRefreshSourceOptions): Promise<BoundedJsonObject> {\n  const input = options.source.input as PublicGithubRepositoryMetricInput;\n  const url = selectGithubRepositoryApiUrl(input);\n  const fetchInit: RequestInit = {\n    headers: {\n      Accept: 'application/vnd.github+json',\n      'User-Agent': 'open-design-live-artifact-refresh',\n    },\n  };\n  if (options.signal !== undefined) fetchInit.signal = options.signal;\n  const response = await fetch(url, fetchInit);\n  if (!response.ok) {\n    throw new Error(`public_github_repository_metric request failed with ${response.status}`);","sourceCodeStart":657,"sourceCodeEnd":693,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/live-artifacts/refresh.ts#L657-L693","documentation":"Thrown by selectGithubFields when input.fields is defined (not undefined) but is not an Array. The fields selector expects either an omitted field (defaults apply) or an array of strings; any other type (object, string, number, null) is rejected before filtering, because the subsequent length-comparison invariant assumes an array.","triggerScenarios":"input.fields is a comma-separated string like 'stargazers_count,full_name'; input.fields is a single string 'stargazers_count'; input.fields is an object {0: '...'}; input.fields is null.","commonSituations":"Model writes fields as a string literal instead of a JSON array; template authoring tool serializes a list as a delimited string; copy-paste from a YAML doc loses array markers; misunderstanding the contract as accepting CSV.","solutions":["Pass input.fields as a JSON array of strings, e.g. ['stargazers_count', 'full_name'].","If you want the defaults, omit input.fields entirely rather than passing null or ''.","Validate at authoring time that Array.isArray(input.fields) before constructing the refresh source."],"exampleFix":"// before\ninput: { url: '...', fields: 'stargazers_count,full_name' }\n// after\ninput: { url: '...', fields: ['stargazers_count', 'full_name'] }","handlingStrategy":"type-guard","validationCode":"function normalizeFields(f: unknown): string[] | undefined {\n  if (f === undefined) return undefined;\n  if (!Array.isArray(f)) throw new Error('input.fields must be a string array');\n  return f as string[];\n}","typeGuard":"function isStringArray(v: unknown): v is string[] {\n  return Array.isArray(v) && v.every(x => typeof x === 'string');\n}","tryCatchPattern":null,"preventionTips":["Always serialize input.fields as a JSON array, never CSV.","Omit the field entirely to take the defaults.","Validate the array shape in the authoring layer before refresh."],"tags":["validation","type-check","github-api","live-artifacts"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}