# How to handle record already exists insert error

**URL:** <https://forum.weaviate.io/t/how-to-handle-record-already-exists-insert-error/8546>\
**Category:** Support\
**Created:** [November 27, 2024, 8:58am UTC](https://forum.weaviate.io/t/how-to-handle-record-already-exists-insert-error/8546 "2024-11-27T08:58:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tejas\_Sharma](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/tejas_sharma/32/2086_2.png) [@Tejas\_Sharma](https://forum.weaviate.io/u/Tejas_Sharma)\
**Post date:** [November 27, 2024, 8:58am UTC](https://forum.weaviate.io/t/how-to-handle-record-already-exists-insert-error/8546/1 "2024-11-27T08:58:49Z")

</div>

If a record already exists, then inserting it will cause a 422 error. However, I’m confused on how to handle this error as it emits an “UnexpectedStatusCodeError”

In this Python code, how can I specifically catch record already exists errors? I tried checking the docs, but couldn’t find how to catch this one as I wish to not raise an exception when it occurs

```auto
try:
		tenant_collection = get_tenant_collection(tenant_name)
		
		uniqueid = tenant_collection.data.insert(
			vector=record.vector,
			properties=record.properties,
			uuid=record.uniqueid
		)

		return uniqueid
	except:
		# if already exists, wil throw 422 error
		print('Error in insert record')
		traceback.print_exc()
		raise Exception("Failed to insert record")

```

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [December 3, 2024, 1:11pm UTC](https://forum.weaviate.io/t/how-to-handle-record-already-exists-insert-error/8546/2 "2024-12-03T13:11:55Z")

</div>

hi! @Tejas_Sharma !!!

Sorry, missed this message (last week was crazy).

Indeed this specific error get only a hint of what happened at the error message, and not raising a specific error.

I have questioned it with our team.

The best route here is to open a feature request at [GitHub - weaviate/weaviate-python-client: A python native client for easy interaction with a Weaviate instance.](https://github.com/weaviate/weaviate-python-client/)

Thanks!
