Skip to content

Commit 1d75656

Browse files
authored
[BUGFIX] Renamed 'response' to 'existing_response' to avoid variable re-declaring (#5383)
# Description When checking collisions of responses to avoid duplicate responses given by the same user to the same question, the response argument is redeclared and the `response.user_id == response.user_id ` will always be satisfied, raising an exception. Closes #5357 **Type of change** - Bug fix (non-breaking change which fixes an issue) **How Has This Been Tested** Changes done locally, installed the local version and tested on top of our Argilla server with this piece of code (details were obfuscated): ``` for user in client.users: record_to_add.responses.add(rg.Response("label_name", label, user_id=user.id, status="submitted")) ```
1 parent b7ac946 commit 1d75656

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

argilla-server/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ These are the section headers that we use:
2020

2121
- Added new endpoint `GET /api/v1/datsets/:dataset_id/users/progress` to compute the users progress. ([#5367](https://github.com/argilla-io/argilla/pull/5367))
2222

23+
### Fixed
24+
25+
- Fixed response duplicate checking ([#5357](https://github.com/argilla-io/argilla/issues/5357))
26+
2327
## [2.0.0](https://github.com/argilla-io/argilla/compare/v2.0.0rc1...v2.0.0)
2428

2529
> [!IMPORTANT]

argilla/src/argilla/records/_resource.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ def add(self, response: Response) -> None:
370370

371371
def _check_response_already_exists(self, response: Response) -> None:
372372
"""Checks if a response for the same question name and user id already exists"""
373-
for response in self.__responses_by_question_name[response.question_name]:
374-
if response.user_id == response.user_id:
373+
for existing_response in self.__responses_by_question_name[response.question_name]:
374+
if existing_response.user_id == response.user_id:
375375
raise ArgillaError(
376376
f"Response for question with name {response.question_name!r} and user id {response.user_id!r} "
377377
f"already found. The responses for the same question name do not support more than one user"

0 commit comments

Comments
 (0)