Skip to content

Raise ResourceNotFoundError when moving data rows to a missing task queue - #2103

Merged
mnoszczak merged 1 commit into
developfrom
mnoszczak/plt-4550
Nov 30, 2026
Merged

mnoszczak merged 1 commit into
developfrom
mnoszczak/plt-4550

Conversation

@mnoszczak

Copy link
Copy Markdown
Contributor

Description

Project.move_data_rows_to_task_queue crashed with a Python TypeError when the task queue id did not exist. It now raises ResourceNotFoundError (a LabelboxError) with a message that says what was missing.

Before

project.move_data_rows_to_task_queue(UniqueIds(["", ""]), "invalid-id")
# TypeError: 'NoneType' object is not subscriptable

Code that catches LabelboxError did not catch this.

After

project.move_data_rows_to_task_queue(UniqueIds(["", ""]), "invalid-id")
# lbox.exceptions.ResourceNotFoundError: Data rows were not moved: task queue 'invalid-id'
# or project '<project id>' was not found (<message from the server>)

The same error is raised when the project itself no longer exists. With task_queue_id=None (the "Done" queue) the message names only the project.

Why it happened

The server answers this call with a RESOURCE_NOT_FOUND error when the task queue or the project is missing. By default Client.execute returns None for that error and leaves it to the caller to raise. move_data_rows_to_task_queue did not check for None and read ["project"][...]["taskId"] straight from the result.

The fix

The method now calls execute with raise_return_resource_not_found=True, the same as Project.clear_queue_reservations does. It catches the ResourceNotFoundError, adds the task queue id and project id to the message, keeps the server's message, and raises it again. Nothing changes for calls that succeed.

Other Project methods

I checked the other methods in project.py that read the result of execute without the flag. I found no other one where a wrong id passed by the caller ends in this TypeError:

  • add_model_config and delete_project_model_config already check for an empty result and raise ResourceNotFoundError.
  • create_batches_from_dataset with an unknown dataset id gets a "malformed request" error from the server, which already raises a LabelboxError.
  • create_batches, create_batch, set_labeling_parameter_overrides, update_data_row_labeling_priority and bulk_assign_data_rows take data row or user ids. As far as I could trace, the server does not answer a wrong one with "not found" on the first call, so they do not reach this path.

The rest only send the id of the project itself (task_queues, get_label_count, get_resource_tags, update_project_resource_tags, export_issues, review_metrics, enable_model_assisted_labeling, project_model_configs). All of the methods above could still fail the same way if the project was deleted after the Project object was fetched. I left them alone to keep this change small.

Tests

New unit tests in tests/unit/test_unit_project_move_data_rows_to_task_queue.py, with a mocked client (no API key needed). One of them sends a real RESOURCE_NOT_FOUND response body through the request client, so it covers the whole path from the server answer to the raised error.

  • Without the fix: 4 of the 5 new tests fail, with TypeError: 'NoneType' object is not subscriptable on the missing-queue path.
  • With the fix: all 5 pass. The whole unit suite passes (521 tests).

New integration test test_move_to_task_invalid_queue_id in tests/integration/test_task_queue.py. It needs a live API key, so I did not run it locally.

Checks run locally: ruff format --check and ruff check on libs/labelbox, and mypy src. All clean.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

All Submissions

  • Have you followed the guidelines in our Contributing document?
  • Have you provided a description?
  • Are your changes properly formatted?

Changes to Core Features

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you updated any code comments, as applicable?

🤖 Generated with Claude Code

…ueue

Project.move_data_rows_to_task_queue raised
"TypeError: 'NoneType' object is not subscriptable" when the task queue
id (or the project) did not exist. The server answers such a call with a
RESOURCE_NOT_FOUND error, the client returned None for it, and the method
read the task id out of that None.

The method now asks the client to raise for a missing resource and
re-raises a ResourceNotFoundError that names the task queue id and the
project id and keeps the server's message.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mnoszczak
mnoszczak merged commit 5023cfb into develop Nov 30, 2026
14 of 24 checks passed
@mnoszczak
mnoszczak deleted the mnoszczak/plt-4550 branch November 30, 2026 15:22
Gabefire added a commit that referenced this pull request Nov 30, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gabefire Gabefire mentioned this pull request Nov 30, 2026

This branch was previously deployed

1 inactive deployment
Test-PyPI — 6b913bea Deployed Nov 30, 2026 by mnoszczak via test-pypi #2585
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants