From 2755b43257f9405ae66a30982d9711fc3f2c0854 Mon Sep 17 00:00:00 2001 From: aaronvg Date: Tue, 2 Jul 2024 18:09:52 -0700 Subject: [PATCH] dont error if user passes in extra fields in a class (#746) --- .../src/ir/ir_helpers/to_baml_arg.rs | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/engine/baml-lib/baml-core/src/ir/ir_helpers/to_baml_arg.rs b/engine/baml-lib/baml-core/src/ir/ir_helpers/to_baml_arg.rs index 3c0c399b0..73b66eb6a 100644 --- a/engine/baml-lib/baml-core/src/ir/ir_helpers/to_baml_arg.rs +++ b/engine/baml-lib/baml-core/src/ir/ir_helpers/to_baml_arg.rs @@ -186,18 +186,15 @@ pub fn validate_arg( } } } else { - // throw an error if there are remaining fields - // instead of dropping them silently - // TODO, these extra dynamic fields should also be validated according to the runtime overrides. - // and we should also render the key by its alias. - for key in obj.keys() { - if !fields.contains_key(key) { - scope.push_error(format!( - "Unexpected field `{}` for class {}. Mark the class as @@dynamic if you want to allow additional fields.", - key, name - )); - } - } + // We let it slide here... but we should probably emit a warning like this: + // for key in obj.keys() { + // if !fields.contains_key(key) { + // scope.push_error(format!( + // "Unexpected field `{}` for class {}. Mark the class as @@dynamic if you want to allow additional fields.", + // key, name + // )); + // } + // } } Some(BamlValue::Class(name.to_string(), fields))