{"record":{"id":"2e9c8702d9052189","repo":"apache/beam","slug":"unknown-type-of-decoding-context","errorCode":null,"errorMessage":"Unknown type of decoding context","messagePattern":"Unknown type of decoding context","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/typescript/src/apache_beam/coders/required_coders.ts","lineNumber":123,"sourceCode":"   *\n   * If the context is `wholeStream`, the whole input stream is decoded as-is.\n   *\n   * @param reader - a reader to access the input byte stream\n   * @param context - whether the data is encoded with delimiters (`Context.needsDelimiters`), or without (`Context.wholeStream`).\n   * @returns\n   */\n  decode(reader: Reader, context: Context): Uint8Array {\n    switch (context) {\n      case Context.wholeStream:\n        return reader.buf.slice(reader.pos);\n        break;\n      case Context.needsDelimiters:\n        var length = reader.int32();\n        var value = reader.buf.slice(reader.pos, reader.pos + length);\n        reader.pos += length;\n        return value;\n      default:\n        throw new Error(\"Unknown type of decoding context\");\n    }\n  }\n\n  toProto(pipelineContext: ProtoContext): runnerApi.Coder {\n    return {\n      spec: {\n        urn: BytesCoder.URN,\n        payload: new Uint8Array(),\n      },\n      componentCoderIds: [],\n    };\n  }\n}\n\nglobalRegistry().register(BytesCoder.URN, BytesCoder);\n\n/**\n * A coder for a key-value pair.","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/typescript/src/apache_beam/coders/required_coders.ts#L105-L141","documentation":"discover_config raises ValueError when the substring name matches more than one SchemaTransform identifier in the expansion service catalog. Because it returns a single config, ambiguity is treated as an error and the matching identifiers are listed in the message. The developer must supply a more specific name.","triggerScenarios":"Calling discover_config with a short or generic substring that matches several identifiers, e.g. discover_config('kafka') matching both kafka_read and kafka_write, or discover_config('read').","commonSituations":"Using broad substrings like 'read', 'write', 'bigquery' when multiple versions/variants of a transform exist; versioned URNs (v1/v2) both matching one substring.","solutions":["Pass a longer, more specific substring that uniquely matches one identifier (e.g. 'kafka_read' instead of 'kafka').","Read the identifiers listed in the error and pick the exact one.","Use the fully qualified identifier if the API accepts it."],"exampleFix":"// before\nSchemaTransforms.discover_config('kafka')  # matches kafka_read and kafka_write\n// after\nSchemaTransforms.discover_config('kafka_read')","handlingStrategy":"validation","validationCode":"matches = [i for i in identifiers if name in i]\nassert len(matches) == 1, f'ambiguous: {matches}'","typeGuard":"def is_unambiguous(name: str, identifiers: list[str]) -> bool:\n    return len([i for i in identifiers if name in i]) == 1","tryCatchPattern":"try:\n    cfg = SchemaTransforms.discover_config(name)\nexcept ValueError as e:\n    identifiers = parse_listed_ids(e)\n    cfg = SchemaTransforms.discover_config(longest(ids_with(name, identifiers)))","preventionTips":["Always use the longest distinctive substring of the identifier","Avoid generic fragments like 'read' or 'write'","Read the ambiguous identifier list in the message and pick exactly one"],"tags":["python","apache-beam","schema-transform","ambiguity","naming"],"backgroundTag":"invalid-identifier","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}