Skip to content

Commit

Permalink
improve error handling for entities, fixes #506.
Browse files Browse the repository at this point in the history
  • Loading branch information
pudo committed Oct 21, 2024
1 parent ad1ab8c commit b7290d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions yente/routers/reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,11 @@ async def reconcile_query(
properties[prop.name].append(p.get("v"))

example = EntityExample(id=None, schema=schema, properties=dict(properties))
proxy = Entity.from_example(example)
query = entity_query(dataset, proxy, fuzzy=False, changed_since=changed_since)
try:
proxy = Entity.from_example(example)
query = entity_query(dataset, proxy, fuzzy=False, changed_since=changed_since)
except Exception as exc:
raise HTTPException(400, detail=str(exc))
resp = await search_entities(provider, query, limit=limit, offset=offset)
algorithm_ = get_algorithm_by_name(algorithm)
entities = result_entities(resp)
Expand Down
3 changes: 3 additions & 0 deletions yente/search/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ def entity_query(
exclude_dataset: List[str] = [],
changed_since: Optional[str] = None,
) -> Clause:
if not entity.schema.matchable:
raise TypeError("Schema is not matchable: %s" % entity.schema.name)

shoulds: List[Clause] = names_query(entity, fuzzy=fuzzy)
for prop, value in entity.itervalues():
if prop.type == registry.name or not prop.matchable:
Expand Down

0 comments on commit b7290d8

Please sign in to comment.