{"record":{"id":"c6fd00a735c238af","repo":"neoclide/coc.nvim","slug":"invalid-pattern-filter-pattern-glob","errorCode":null,"errorMessage":"Invalid pattern ${filter.pattern.glob}!","messagePattern":"Invalid pattern (.+?)!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/language-client/fileOperations.ts","lineNumber":116,"sourceCode":"      } catch (e) {\n        this._client.warn(\n          `Ignoring invalid glob pattern for ${this._serverCapability} registration: ${e}`\n        )\n      }\n    }\n  }\n\n  public register(data: RegistrationData<FileOperationRegistrationOptions>): void {\n    if (!this._listener) {\n      this._listener = this._event(this.send, this)\n    }\n    const minimatchFilter = data.registerOptions.filters.map(filter => {\n      const matcher = new minimatch.Minimatch(\n        filter.pattern.glob,\n        FileOperationFeature.asMinimatchOptions(filter.pattern.options)\n      )\n      if (!matcher.makeRe()) {\n        throw new Error(`Invalid pattern ${filter.pattern.glob}!`)\n      }\n      return { scheme: filter.scheme, matcher, kind: filter.pattern.matches }\n    })\n    this._filters.set(data.id, minimatchFilter)\n  }\n\n  public sendWithMiddleware<T>(fn: (...args: any[]) => Promise<T> | T, key: string, ...params: any[]): Promise<T> | T {\n    const middleware = defaultValue(defaultValue(this._client.middleware, {}).workspace, {})\n    return middleware[key] ? middleware[key](...params, fn) : fn(...params)\n  }\n\n  public abstract send(data: E): Promise<void>\n\n  public unregister(id: string): void {\n    this._filters.delete(id)\n  }\n\n  public dispose(): void {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/language-client/fileOperations.ts#L98-L134","documentation":"During FileOperationFeature registration the client compiles each filter's glob into a regex via minimatch's makeRe(). If the glob is empty or syntactically invalid, makeRe() returns null and registration fails with this error, preventing an unusable file-operation watcher.","triggerScenarios":"Registering file operations (create/rename/delete watchers) via initialize with a filter whose pattern.glob is '' or contains invalid glob syntax (e.g. unbalanced brackets, bad ** placement).","commonSituations":"Extension authors hand-writing fileWatching patterns; config-driven globs read from user settings that are empty strings; server capability registration with malformed relativePattern globs.","solutions":["Fix the glob string in the registration options (e.g. '**/*.ts' instead of '')","Validate globs with new Minimatch(glob).makeRe() before registering","Guard config-derived globs with a default fallback","Check the server/extension version for glob-generation bugs"],"exampleFix":"// before\nfilters: [{ pattern: { glob: '' } }]\n// after\nfilters: [{ pattern: { glob: '**/*.{ts,js}' } }]","handlingStrategy":"validation","validationCode":"import * as minimatch from 'minimatch'\nfunction isValidGlob(glob: string, options?: minimatch.IOptions): boolean {\n  if (!glob) return false\n  try { return new minimatch.Minimatch(glob, options).makeRe() !== null } catch { return false }\n}\n// validate each filter.pattern.glob before registering file operations","typeGuard":"function hasValidPattern(f: { pattern: { glob: string } }): boolean {\n  return typeof f.pattern?.glob === 'string' && f.pattern.glob.length > 0\n}","tryCatchPattern":"try {\n  registerFileOperations(opts)\n} catch (e) {\n  if (String(e.message).startsWith('Invalid pattern')) {\n    console.error('Fix glob in registration options:', e.message)\n  } else { throw e }\n}","preventionTips":["Never pass empty-string globs; default to '**/*' when unset","Unit-test registration options with makeRe() before shipping","Validate user-configured globs at config-load time","Keep glob syntax simple (**, *, {}) to avoid minimatch parse failures"],"tags":["glob","minimatch","validation","file-watching"],"backgroundTag":"invalid-glob-pattern","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}