{"record":{"id":"c110745aa0056a7d","repo":"microsoft/playwright","slug":"path-expected-dispatcher-names-tostring","errorCode":null,"errorMessage":"${path}: expected dispatcher ${names.toString()}","messagePattern":"(.+?): expected dispatcher (.+?)","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/dispatchers/dispatcher.ts","lineNumber":262,"sourceCode":"    if (arg && typeof arg === 'object' && typeof arg.guid === 'string') {\n      const guid = arg.guid;\n      const dispatcher = this._dispatcherByGuid.get(guid);\n      if (!dispatcher)\n        throw new ValidationError(`${path}: no object with guid ${guid}`);\n      if (names !== '*' && !names.includes(dispatcher._type))\n        throw new ValidationError(`${path}: object with guid ${guid} has type ${dispatcher._type}, expected ${names.toString()}`);\n      return dispatcher;\n    }\n    throw new ValidationError(`${path}: expected guid for ${names.toString()}`);\n  }\n\n  private _tChannelImplToWire(names: '*' | string[], arg: any, path: string, context: ValidatorContext): any {\n    if (arg instanceof Dispatcher)  {\n      if (names !== '*' && !names.includes(arg._type))\n        throw new ValidationError(`${path}: dispatcher with guid ${arg._guid} has type ${arg._type}, expected ${names.toString()}`);\n      return { guid: arg._guid };\n    }\n    throw new ValidationError(`${path}: expected dispatcher ${names.toString()}`);\n  }\n\n  existingDispatcher<DispatcherType>(object: any): DispatcherType | undefined {\n    return this._dispatcherByObject.get(object) as DispatcherType | undefined;\n  }\n\n  registerDispatcher(dispatcher: DispatcherScope) {\n    assert(!this._dispatcherByGuid.has(dispatcher._guid));\n    this._dispatcherByGuid.set(dispatcher._guid, dispatcher);\n    this._dispatcherByObject.set(dispatcher._object, dispatcher);\n    let list = this._dispatchersByBucket.get(dispatcher._gcBucket);\n    if (!list) {\n      list = new Set();\n      this._dispatchersByBucket.set(dispatcher._gcBucket, list);\n    }\n    list.add(dispatcher._guid);\n  }\n","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/dispatchers/dispatcher.ts#L244-L280","documentation":"ValidationError raised in _tChannelImplToWire when a result field declared as a channel is being serialized from a value that is not a Dispatcher instance. The outbound serializer expects an actual Dispatcher object; receiving anything else (plain object, undefined, null, a raw guid string) means server code returned the wrong shape for a channel field.","triggerScenarios":"Server-side method returns a non-Dispatcher (undefined, plain object, or a guid) for a result field whose validator requires a channel. As with error 276, this is internal to Playwright and typically follows a code/protocol edit that broke the return shape.","commonSituations":"Editing Playwright internals (returning undefined from a dispatcher method, forgetting to wrap an object in its Dispatcher); stale generated validators after protocol changes.","solutions":["If modifying Playwright: return the proper Dispatcher (e.g. new PageDispatcher(...)) for every channel result field; rebuild to regenerate validators.","Run npm run flint / watch so generated code matches protocol.yml.","End users: this signals a Playwright bug — file an issue with a repro."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await connection.dispatch(...);\n} catch (e) {\n  if (/expected dispatcher/.test(e.message)) {\n    throw new Error('Playwright internal: a channel result field was not a Dispatcher — rebuild/regenerate');\n  }\n  throw e;\n}","preventionTips":["Ensure every dispatcher method returns the proper Dispatcher subtype for each channel result field.","Rebuild (watch / npm run build) after editing protocol or dispatcher return shapes so validators regenerate.","Run npm run flint to catch channel/validator drift early."],"tags":["protocol","validation","internal","dispatcher","wire-format"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}