Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
grpc: FileMatch: tweak file_name to be bytes instead of string
In gRPC, all strings must be valid utf-8 sequences. However, there is no guarantee that the file path we receive is valid-utf8 (from Sourcegraph or another source). See https://cloudlogging.app.goo.gl/aWr5in5axbVWGntd6 for an example of this error on sourcegraph.com: ``` { "jsonPayload": { "Caller": "internalerrs/logging.go:236", "Body": "grpc: error while marshaling: string field contains invalid UTF-8", "Resource": { "service.name": "zoekt-webserver", "service.instance.id": "indexed-search-15" }, "Attributes": { "initialRequestJSON": "{\"query\":{\"Query\":{\"And\":{\"children\":[{\"Query\":{\"Substring\":{\"pattern\":\"typeof window\"}}},{\"Query\":{\"Branch\":{\"pattern\":\"HEAD\",\"exact\":true}}},{\"Query\":{\"RawConfig\":{\"flags\":[1,8,32]}}}]}}},\"opts\":{\"shard_max_match_count\":99999999,\"total_max_match_count\":99999999,\"max_wall_time\":{\"seconds\":54,\"nanos\":901824329},\"flush_wall_time\":{\"seconds\":1},\"max_doc_display_count\":99999999,\"chunk_matches\":true,\"use_document_ranks\":true,\"document_ranks_weight\":4500}}", "messageJSON": "{\"stats\":{\"duration\":{},\"wait\":{},\"match_tree_construction\":{},\"match_tree_search\":{}},\"progress\":{\"priority\":27,\"max_pending_priority\":101},\"files\":[{\"score\":774.0376017917057,\"file_name\":\"Ch1/1-8\\ufffd\\ufffd\\ufffd\\ufffd\\ufffd\\ufffdͻ/lib/prototype.js\",\"repository\":\"github.com/cssrain/Sharp-jQuery-Source\",\"branches\":[\"HEAD\"],\"chunk_matches\":[{\"content\":\"ICAgICAgaWYgKHR5cGVvZiB3aW5kb3cuSFRNTERpdkVsZW1lbnQgIT09ICd1bmRlZmluZWQnKQ==\",\"content_start\":{\"byte_offset\":1102,\"line_number\":35,\"column\":1},\"ranges\":[{\"start\":{\"byte_offset\":1112,\"line_number\":35,\"column\":11},\"end\":{\"byte_offset\":1125,\"line_number\":35,\"column\":24}}],\"score\":501},{\"content\":\"ICAgIGlmICh0eXBlb2Ygd2luZG93LkVsZW1lbnQgIT0gJ3VuZGVmaW5lZCcpIHs=\",\"content_start\":{\"byte_offset\":78805,\"line_number\":2887,\"column\":1},\"ranges\":[{\"start\":{\"byte_offset\":78813,\"line_number\":2887,\"column\":9},\"end\":{\"byte_offset\":78826,\"line_number\":2887,\"column\":22}}],\"score\":500.5}],\"repository_id\":35867662,\"repository_priority\":27,\"checksum\":\"N50W...(truncated 1324 bytes)", "grpcCode": "Internal", "nonUTF8StringFields": [ "files[0].file_name" ], "grpcService": "grpc.v1.WebserverService", "grpcMethod": "StreamSearch" }, } ```
- Loading branch information