From d6a061c006985dc95e4999ec948d75a3781393f7 Mon Sep 17 00:00:00 2001 From: Matt Stone Date: Tue, 8 Oct 2024 09:57:13 -0400 Subject: [PATCH 1/2] feat: Report all fields which fail registry transformation --- latch/registry/table.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/latch/registry/table.py b/latch/registry/table.py index eb574f55..c3a23ff9 100644 --- a/latch/registry/table.py +++ b/latch/registry/table.py @@ -486,14 +486,21 @@ def upsert_record(self, name: str, **values: RegistryPythonValue) -> None: cols = self.table.get_columns() db_vals: Dict[str, DBValue] = {} + errs: List[str] = [] for k, v in values.items(): col = cols.get(k) if col is None: raise NoSuchColumnError(k) - db_vals[k] = to_registry_literal( - v, col.upstream_type["type"], resolve_paths=False - ) + try: + db_vals[k] = to_registry_literal( + v, col.upstream_type["type"], resolve_paths=False + ) + except RegistryTransformerException as e: + errs.append(f"\tCould not convert field '{k}' with value {v} to type {col.upstream_type['type']}: {e}") + + if len(errs) > 0: + raise RegistryTransformerException(f"Could not upsert record {name}:" + "\n".join(errs)) self._record_mutations.append(_TableRecordsUpsertData(name, db_vals)) From e0b322a4551b72e01c7f0ad0ddb08ba6fcd32139 Mon Sep 17 00:00:00 2001 From: Matt Stone Date: Wed, 16 Oct 2024 20:35:22 -0400 Subject: [PATCH 2/2] Update latch/registry/table.py Co-authored-by: Ayush Kamat <34531970+ayushkamat@users.noreply.github.com> --- latch/registry/table.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/latch/registry/table.py b/latch/registry/table.py index c3a23ff9..87ce62bf 100644 --- a/latch/registry/table.py +++ b/latch/registry/table.py @@ -497,7 +497,8 @@ def upsert_record(self, name: str, **values: RegistryPythonValue) -> None: v, col.upstream_type["type"], resolve_paths=False ) except RegistryTransformerException as e: - errs.append(f"\tCould not convert field '{k}' with value {v} to type {col.upstream_type['type']}: {e}") + # todo(ayush): add a registry_type -> pretty string fn so we aren't printing json here + errs.append(f"Error converting field {repr(k)} with value {repr(v)} to type {col.upstream_type['type']}: {e}") if len(errs) > 0: raise RegistryTransformerException(f"Could not upsert record {name}:" + "\n".join(errs))