{"record":{"id":"7818d8791c338297","repo":"deepseek-ai/deepseek-harness","slug":"context-not-found","errorCode":"context-not-found","errorMessage":"Context provider ${JSON.stringify(invocation.context)} did not resolve the requested identity","messagePattern":"Context provider (.+?) did not resolve the requested identity","errorType":"exception","errorClass":"TypertGatewayError","httpStatus":null,"severity":"error","filePath":"packages/api/gateway/src/index.ts","lineNumber":397,"sourceCode":"        `Context provider ${JSON.stringify(invocation.context)} does not match its strict definition`,\n        { field: invocation.wire },\n      )\n    }\n    const identity = decode(invocation.codec, args[invocation.wire], 'input-invalid', endpoint, invocation.wire)\n    let context: Context | undefined\n    try {\n      context = await provider.resolve(identity)\n    } catch (cause) {\n      if (cause instanceof TypertLookupFailure) throw cause\n      throw new TypertGatewayError(\n        'context-failed',\n        endpoint,\n        `Context provider ${JSON.stringify(invocation.context)} failed`,\n        { cause, field: invocation.wire },\n      )\n    }\n    if (context === undefined) {\n      throw new TypertGatewayError(\n        'context-not-found',\n        endpoint,\n        `Context provider ${JSON.stringify(invocation.context)} did not resolve the requested identity`,\n        { field: invocation.wire },\n      )\n    }\n    return context\n  }\n\n  private async resolveParameter(\n    parameter: InvocationParameterDescriptor,\n    args: Readonly<Record<string, unknown>>,\n    endpoint: string,\n  ): Promise<unknown> {\n    // An absent field reached assertExactArguments' allowance, so this parameter\n    // takes undefined; a present-but-undefined field is not JSON-safe input and\n    // still fails decode. Lookup ids are never omissible, so absence here only\n    // ever belongs to a json parameter.","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/api/gateway/src/index.ts#L379-L415","documentation":"The Host Context provider resolved without throwing but returned undefined: the identity carried by the invocation's wire field does not map to any live scoped Context. This is the 404-equivalent for context-scoped remotes — the request shape was valid and the provider is healthy, but that identity no longer (or never) exists on this host.","triggerScenarios":"Calling a 'session:<ns>/<method>' endpoint with a sessionId whose session expired, was disposed, or belongs to a different host instance; using an identity captured before a host restart.","commonSituations":"Client reconnects after a server restart with a persisted session id; session TTL expiry mid-workflow; load-balanced routing sends the call to a node that does not hold that scoped Context; an id copied from another environment.","solutions":["Re-acquire a fresh identity (re-run the session/terminal bootstrap) and retry the call once.","If the identity should be valid, check host affinity — route to the node that owns the scoped Context or restore its backing store.","Treat it as a terminal 404 in client logic: do not blind-retry the same identity."],"exampleFix":"// before — one-shot call with a possibly stale identity\nawait scopedRemote.send({ text })\n// → context-not-found after the scoped Context expired\n\n// after — fall back to a fresh identity and retry once\ntry {\n  await scopedRemote.send({ text })\n} catch (error) {\n  if (isContextNotFound(error)) {\n    await reestablishScope()\n    await scopedRemote.send({ text })\n  } else throw error\n}","handlingStrategy":"fallback","validationCode":"import type { TypertHostContextProvider } from '@deepseek-ai/dsh-typert-protocol'\n\n// Host-side callers can pre-validate the identity against the provider.\nasync function identityIsLive(provider: TypertHostContextProvider, id: unknown): Promise<boolean> {\n  return (await provider.resolve(id)) !== undefined\n}","typeGuard":"import { TypertGatewayError } from '@deepseek-ai/dsh-api-gateway'\n\nfunction isContextNotFound(error: unknown): error is TypertGatewayError {\n  return error instanceof TypertGatewayError && error.code === 'context-not-found'\n}","tryCatchPattern":"try {\n  return await gateway.invoke(request)\n} catch (error) {\n  if (error instanceof TypertGatewayError && error.code === 'context-not-found') {\n    const fresh = await reestablishScope() // fallback: new identity, single retry\n    const args = { ...(request.args as Record<string, unknown>), [error.field ?? 'sessionId']: fresh }\n    return gateway.invoke({ ...request, args })\n  }\n  throw error\n}","preventionTips":["Refresh identities after host restarts and reconnections instead of persisting them indefinitely.","Expire client-side cached ids on the same TTL the scoped Context uses.","Map context-not-found onto your client's 404 handling path — never onto a generic internal-error path."],"tags":["typert","gateway","context-provider","not-found","identity","rpc"],"backgroundTag":"entity-not-found","analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}