{"record":{"id":"025269827686cc57","repo":"deepseek-ai/deepseek-harness","slug":"context-failed","errorCode":"context-failed","errorMessage":"Context provider ${JSON.stringify(invocation.context)} failed","messagePattern":"Context provider (.+?) failed","errorType":"exception","errorClass":"TypertGatewayError","httpStatus":null,"severity":"error","filePath":"packages/api/gateway/src/index.ts","lineNumber":389,"sourceCode":"        `Context provider ${JSON.stringify(invocation.context)} is unavailable`,\n      )\n    }\n    if (provider.wire !== invocation.wire\n      || (invocation.codec.mode === 'strict' && provider.wireTypeSymbol !== invocation.codec.typeSymbol)) {\n      throw new TypertGatewayError(\n        'provider-mismatch',\n        endpoint,\n        `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(","sourceCodeStart":371,"sourceCodeEnd":407,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/api/gateway/src/index.ts#L371-L407","documentation":"The Host Context provider's resolve(identity) threw an exception that is not a TypertLookupFailure (those keep their own failure identity on the wire). The Gateway wraps the original error as context-failed with the cause attached and the identity wire field in field — an infrastructure failure inside the provider (backing store, resolver bug), not a malformed request.","triggerScenarios":"provider.resolve awaiting a database or file lookup that rejects (session store down, EACCES on the state directory), or resolver code throwing on an unexpected internal state, while resolveReceiverContext builds the receiver Context for a context-scoped endpoint.","commonSituations":"Session/state store outage behind the provider; a resolver that throws instead of returning undefined for unknown ids; transient I/O errors; unhandled rejections inside provider code.","solutions":["Inspect error.cause — the provider's original exception carries the real failure; fix that (restore the store, repair permissions, fix the bug).","In the provider, return undefined for well-formed but unknown identities so they surface as context-not-found instead of context-failed.","If the cause is transient (network blip, store restart), retry the invoke once the backing service is healthy."],"exampleFix":"// before — provider throws on missing rows, so absent ids surface as context-failed\nresolve: async (id: string) => {\n  const row = await store.get(`session:${id}`) // store.get rejects on not-found\n  return toContext(row)\n}\n// after — absent identity returns undefined → context-not-found; only real errors throw\nresolve: async (id: string) => {\n  const row = await store.get(`session:${id}`)\n  return row === null ? undefined : toContext(row)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"import { TypertGatewayError } from '@deepseek-ai/dsh-api-gateway'\n\nfunction isContextFailed(error: unknown): error is TypertGatewayError {\n  return error instanceof TypertGatewayError && error.code === 'context-failed'\n}","tryCatchPattern":"try {\n  await gateway.invoke(request)\n} catch (error) {\n  if (error instanceof TypertGatewayError && error.code === 'context-failed') {\n    // infrastructure failure: log the cause chain and surface as 5xx, never as a business 404\n    logger.error('context provider failure', { endpoint: error.endpoint, field: error.field, cause: error.cause })\n    throw error\n  }\n  throw error\n}","preventionTips":["Make provider resolvers total: catch known miss conditions and return undefined; let only genuine failures propagate.","Distinguish 'unknown identity' (return undefined → context-not-found) from 'lookup crashed' (throw → context-failed) in every resolver you write.","Monitor context-failed on a separate alert path from context-not-found: the first pages a human, the second is normal traffic."],"tags":["typert","gateway","context-provider","error-cause","infrastructure"],"backgroundTag":"upstream-dependency-error","analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}