From d3a04369923c9dc4b969b0b6c51ca445f5651871 Mon Sep 17 00:00:00 2001 From: "Delta Pham (they/them)" <1707217+dphm@users.noreply.github.com> Date: Mon, 8 Jan 2024 14:19:10 -0500 Subject: [PATCH] Handle non-utf8 paths and files without extensions Co-authored-by: Surma --- graphql_client_codegen/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graphql_client_codegen/src/lib.rs b/graphql_client_codegen/src/lib.rs index dcc79426..e21adee2 100644 --- a/graphql_client_codegen/src/lib.rs +++ b/graphql_client_codegen/src/lib.rs @@ -80,8 +80,8 @@ fn get_set_schema_from_file(schema_path: &std::path::Path) -> Schema { get_set_cached(&SCHEMA_CACHE, schema_path, move || { let schema_extension = schema_path .extension() - .and_then(std::ffi::OsStr::to_str) - .unwrap_or("INVALID"); + .map(|ext| ext.to_str().expect("Path must be valid UTF-8")) + .unwrap_or(""); let schema_string = read_file(schema_path).unwrap(); match schema_extension { "graphql" | "gql" => {