-
Notifications
You must be signed in to change notification settings - Fork 78
Closed
Labels
Description
Papermerge version: 3.0.3
Steps to replicate the issue:
- Create a folder
- Create 2 tags
- Assign the first tag to a folder (
POSTrequest on/api/nodes/{node_id}/tags) - Try to append the second tag to a folder (
PATCHrequest on/api/nodes/{node_id}/tags)
More details:
- List of nodes in the
.homefolder (id=7834c35e-f77a-4fe0-aa85-ddbc5b65b234)
curl --location 'http://127.0.0.1:16000/api/nodes/7834c35e-f77a-4fe0-aa85-ddbc5b65b234' \
--header 'Authorization: Bearer ***REDACTED***'
Response:
{
"page_size": 5,
"page_number": 1,
"num_pages": 1,
"items": [
{
"id": "fd0a95eb-33ff-4ecd-8744-80110644da15",
"title": "Test Folder",
"ctype": "folder",
"tags": [],
"created_at": "2024-02-08T07:40:32.759830Z",
"updated_at": "2024-02-08T07:40:32.760262Z",
"parent_id": "7834c35e-f77a-4fe0-aa85-ddbc5b65b234",
"user_id": "1697364d-9cbb-48f0-91a1-00632b6b14a3",
"breadcrumb": []
}
]
}- List of tags
curl --location 'http://127.0.0.1:16000/api/tags/' \
--header 'Authorization: Bearer ***REDACTED***'
Response:
{
"page_size": 5,
"page_number": 1,
"num_pages": 1,
"items": [
{
"id": "9ea76967-2416-4305-8627-bd67379236ea",
"name": "Tag1",
"bg_color": "#c41fff",
"fg_color": "#ffffff",
"description": null,
"pinned": false
},
{
"id": "e9893ee2-afc4-4883-aedf-06b7098d3f6b",
"name": "Tag2",
"bg_color": "#c41fff",
"fg_color": "#ffffff",
"description": null,
"pinned": false
}
]
}- Assign
Tag1to theTest Folder(folder_id=fd0a95eb-33ff-4ecd-8744-80110644da15)
curl --location 'http://127.0.0.1:16000/api/nodes/fd0a95eb-33ff-4ecd-8744-80110644da15/tags' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ***REDACTED***' \
--data '[
"Tag1"
]'
Response:
{
"id": "fd0a95eb-33ff-4ecd-8744-80110644da15",
"title": "Test Folder",
"ctype": "folder",
"tags": [
{
"name": "Tag1",
"bg_color": "#c41fff",
"fg_color": "#ffffff"
}
],
"created_at": "2024-02-08T07:40:32.759830Z",
"updated_at": "2024-02-08T07:40:32.760262Z",
"parent_id": "7834c35e-f77a-4fe0-aa85-ddbc5b65b234",
"user_id": "1697364d-9cbb-48f0-91a1-00632b6b14a3",
"document": null
}- Try to append
Tag2to theTest Folder(folder_id=fd0a95eb-33ff-4ecd-8744-80110644da15)
curl --location --request PATCH 'http://127.0.0.1:16000/api/nodes/fd0a95eb-33ff-4ecd-8744-80110644da15/tags' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ***REDACTED***' \
--data '[
"Tag2"
]'
Response:
Internal Server Error
Traceback:
Exception in ASGI application
Traceback (most recent call last):
File "/core_app/.venv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 2688, in to_python
return uuid.UUID(**{input_form: value})
File "/usr/local/lib/python3.10/uuid.py", line 174, in __init__
hex = hex.replace('urn:', '').replace('uuid:', '')
File "/core_app/.venv/lib/python3.10/site-packages/pydantic/main.py", line 761, in __getattr__
raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}')
AttributeError: 'User' object has no attribute 'replace'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/core_app/.venv/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/core_app/.venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
return await self.app(scope, receive, send)
File "/core_app/.venv/lib/python3.10/site-packages/fastapi/applications.py", line 289, in __call__
await super().__call__(scope, receive, send)
File "/core_app/.venv/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
await self.middleware_stack(scope, receive, send)
File "/core_app/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/core_app/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/core_app/.venv/lib/python3.10/site-packages/starlette/middleware/cors.py", line 83, in __call__
await self.app(scope, receive, send)
File "/core_app/.venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/core_app/.venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/core_app/.venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
raise e
File "/core_app/.venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
await self.app(scope, receive, send)
File "/core_app/.venv/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
await route.handle(scope, receive, send)
File "/core_app/.venv/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/core_app/.venv/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/core_app/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 273, in app
raw_response = await run_endpoint_function(
File "/core_app/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 192, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
File "/core_app/.venv/lib/python3.10/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
return await anyio.to_thread.run_sync(func, *args)
File "/core_app/.venv/lib/python3.10/site-packages/anyio/to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
File "/core_app/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2134, in run_sync_in_worker_thread
return await future
File "/core_app/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 851, in run
result = context.run(func, *args)
File "/core_app/papermerge/core/routers/nodes.py", line 279, in update_node_tags
node.tags.add(*tags, tag_kwargs={"user": user})
File "/core_app/.venv/lib/python3.10/site-packages/taggit/utils.py", line 124, in inner
return func(self, *args, **kwargs)
File "/core_app/.venv/lib/python3.10/site-packages/taggit/managers.py", line 158, in add
tag_objs = self._to_tag_model_instances(tags, tag_kwargs)
File "/core_app/.venv/lib/python3.10/site-packages/taggit/managers.py", line 236, in _to_tag_model_instances
existing = manager.filter(name__in=str_tags, **tag_kwargs)
File "/core_app/.venv/lib/python3.10/site-packages/django/db/models/query.py", line 1436, in filter
return self._filter_or_exclude(False, args, kwargs)
File "/core_app/.venv/lib/python3.10/site-packages/django/db/models/query.py", line 1454, in _filter_or_exclude
clone._filter_or_exclude_inplace(negate, args, kwargs)
File "/core_app/.venv/lib/python3.10/site-packages/django/db/models/query.py", line 1461, in _filter_or_exclude_inplace
self._query.add_q(Q(*args, **kwargs))
File "/core_app/.venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1546, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
File "/core_app/.venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1577, in _add_q
child_clause, needed_inner = self.build_filter(
File "/core_app/.venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1492, in build_filter
condition = self.build_lookup(lookups, col, value)
File "/core_app/.venv/lib/python3.10/site-packages/django/db/models/sql/query.py", line 1319, in build_lookup
lookup = lookup_class(lhs, rhs)
File "/core_app/.venv/lib/python3.10/site-packages/django/db/models/lookups.py", line 27, in __init__
self.rhs = self.get_prep_lookup()
File "/core_app/.venv/lib/python3.10/site-packages/django/db/models/fields/related_lookups.py", line 166, in get_prep_lookup
self.rhs = target_field.get_prep_value(self.rhs)
File "/core_app/.venv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 2672, in get_prep_value
return self.to_python(value)
File "/core_app/.venv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 2690, in to_python
raise exceptions.ValidationError(
django.core.exceptions.ValidationError: ["“id=UUID('1697364d-9cbb-48f0-91a1-00632b6b14a3') username='***REDACTED***' email='***REDACTED***' created_at=datetime.datetime(2024, 2, 2, 10, 44, 50, 727694, tzinfo=datetime.timezone.utc) updated_at=datetime.datetime(2024, 2, 2, 10, 44, 50, 811990, tzinfo=datetime.timezone.utc) home_folder_id=UUID('7834c35e-f77a-4fe0-aa85-ddbc5b65b234') inbox_folder_id=UUID('852fb2a2-7a76-4c0a-89a3-1a051cfb4bd5')” is not a valid UUID."]
ciur