{"record":{"id":"56e33760b39d06f7","repo":"neoclide/coc.nvim","slug":"illegal-argument-base","errorCode":null,"errorMessage":"Illegal argument: base","messagePattern":"Illegal argument: base","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/model/relativePattern.ts","lineNumber":13,"sourceCode":"'use strict'\nimport { URI } from 'vscode-uri'\nimport { illegalArgument } from '../util/errors'\nimport { WorkspaceFolder } from 'vscode-languageserver-types'\n\nexport default class RelativePattern {\n  public pattern: string\n  public baseUri: URI\n\n  constructor(base: WorkspaceFolder | URI | string, pattern: string) {\n    if (typeof base !== 'string') {\n      if (!base || !URI.isUri(base) && typeof base.uri !== 'string') {\n        throw illegalArgument('base')\n      }\n    }\n    if (typeof pattern !== 'string') {\n      throw illegalArgument('pattern')\n    }\n    if (typeof base === 'string') {\n      this.baseUri = URI.file(base)\n    } else if (URI.isUri(base)) {\n      this.baseUri = base\n    } else {\n      this.baseUri = URI.parse(base.uri)\n    }\n    this.pattern = pattern\n  }\n\n  public toJSON() {\n    return {\n      pattern: this.pattern,","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/model/relativePattern.ts#L1-L31","documentation":"The RelativePattern constructor validates its base argument: it must be a plain string path, a URI instance, or an object with a string .uri property (a WorkspaceFolder). Anything else (null, undefined, a plain object without uri) triggers illegalArgument('base'), reported as \"Illegal argument: base\".","triggerScenarios":"new RelativePattern(undefined, '**/*.ts'), passing a WorkspaceFolder-like object whose uri is not a string, or passing a null base.","commonSituations":"Destructuring a workspace folder before it is assigned; using a vscode.Uri from a different coc/vscode module instance so URI.isUri fails and the .uri fallback also misses; copying code from VS Code API where base types differ.","solutions":["Pass a string path, a proper URI (workspace.createFileRangeUri/Uri.file), or a real WorkspaceFolder.","Guard base for null/undefined before constructing the pattern.","Ensure the object's .uri is a string; convert URI objects to strings with .toString() if needed.","Avoid mixing Uri implementations from different module copies."],"exampleFix":"// before\nconst rp = new RelativePattern(maybeFolder, '**/*.ts')\n// after\nif (maybeFolder && (typeof maybeFolder === 'string' || typeof maybeFolder.uri === 'string')) {\n  const rp = new RelativePattern(maybeFolder, '**/*.ts')\n}","handlingStrategy":"type-guard","validationCode":"if (!(typeof base === 'string' || (base && typeof base.uri === 'string'))) throw new Error('RelativePattern base must be a string or folder-like')","typeGuard":"function isRelativePatternBase(v: unknown): v is string | { uri: string } {\n  return typeof v === 'string' || (!!v && typeof (v as any).uri === 'string')\n}","tryCatchPattern":"try { const rp = new RelativePattern(base, glob) } catch (e) { if (String(e).includes('Illegal argument: base')) { /* normalize base to Uri.file(...) and retry */ } else throw e }","preventionTips":["Always construct base with Uri.file(path) or take it from workspace APIs","Guard nullable workspace folder variables","Avoid mixing Uri classes from duplicate coc.nvim module copies"],"tags":["argument-validation","filesystem-watcher","type-error"],"backgroundTag":"illegal-argument","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}