neoclide/coc.nvim · error · Error
Invalid pattern ${filter.pattern.glob}!
Error message
Invalid pattern ${filter.pattern.glob}! What it means
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.
Source
Thrown at src/language-client/fileOperations.ts:116
} catch (e) {
this._client.warn(
`Ignoring invalid glob pattern for ${this._serverCapability} registration: ${e}`
)
}
}
}
public register(data: RegistrationData<FileOperationRegistrationOptions>): void {
if (!this._listener) {
this._listener = this._event(this.send, this)
}
const minimatchFilter = data.registerOptions.filters.map(filter => {
const matcher = new minimatch.Minimatch(
filter.pattern.glob,
FileOperationFeature.asMinimatchOptions(filter.pattern.options)
)
if (!matcher.makeRe()) {
throw new Error(`Invalid pattern ${filter.pattern.glob}!`)
}
return { scheme: filter.scheme, matcher, kind: filter.pattern.matches }
})
this._filters.set(data.id, minimatchFilter)
}
public sendWithMiddleware<T>(fn: (...args: any[]) => Promise<T> | T, key: string, ...params: any[]): Promise<T> | T {
const middleware = defaultValue(defaultValue(this._client.middleware, {}).workspace, {})
return middleware[key] ? middleware[key](...params, fn) : fn(...params)
}
public abstract send(data: E): Promise<void>
public unregister(id: string): void {
this._filters.delete(id)
}
public dispose(): void {View on GitHub (pinned to 50e974d969)
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
Example fix
// before
filters: [{ pattern: { glob: '' } }]
// after
filters: [{ pattern: { glob: '**/*.{ts,js}' } }] Defensive patterns
Strategy: validation
Validate before calling
import * as minimatch from 'minimatch'
function isValidGlob(glob: string, options?: minimatch.IOptions): boolean {
if (!glob) return false
try { return new minimatch.Minimatch(glob, options).makeRe() !== null } catch { return false }
}
// validate each filter.pattern.glob before registering file operations Type guard
function hasValidPattern(f: { pattern: { glob: string } }): boolean {
return typeof f.pattern?.glob === 'string' && f.pattern.glob.length > 0
} Try / catch
try {
registerFileOperations(opts)
} catch (e) {
if (String(e.message).startsWith('Invalid pattern')) {
console.error('Fix glob in registration options:', e.message)
} else { throw e }
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: Extension authors hand-writing fileWatching patterns; config-driven globs read from user settings that are empty strings; server capability registration with malformed relativePattern globs.
Related errors
- name and doComplete required for createSource
- Feature param could only starts with nvim and patch
- Invalid key ${name} of registerKeymap
- Invalid extension name: ${name}
- Invalid action ${action}
AI-assisted analysis of neoclide/coc.nvim@50e974d969 (2026-08-31).
Data as JSON: /api/errors/c6fd00a735c238af.
Report an issue: GitHub.