Skip to content

fix(tasks): mirror parent_id to Project body for BatchTask create - #574

Open
prasad-albert wants to merge 2 commits into
mainfrom
worktree-sdk-audit
Open

fix(tasks): mirror parent_id to Project body for BatchTask create#574
prasad-albert wants to merge 2 commits into
mainfrom
worktree-sdk-audit

Conversation

@prasad-albert

Copy link
Copy Markdown
Collaborator

Summary

  • BatchTask.create with parent_id set but project omitted caused a server-side runtime crash — the API requires the Project entity link in the request body for ACL resolution alongside the parentId query param
  • Fix auto-populates {"Project": {"id": parent_id}} in the payload for BatchTask when project is not already present
  • Corrects PropertyTask docstring: parent_id is the parent inventory item ID, not a project ID

@claude

claude Bot commented Jun 30, 2026

Copy link
Copy Markdown

Looks good - no bugs or correctness issues found.

Comment thread src/albert/resources/tasks.py Outdated
The location where the property task is performed.
parent_id : str
The ID of the parent project.
The ID of the parent inventory item.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waiting on confirmation of what exactly parentId is here? inventory or project

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The agent worker workaround mirrors parent_id → project for PropertyTask.This PR does two things that point the other way:

In create(), it mirrors parent_id → Project body only for BatchTask (isinstance(task, BatchTask)), not PropertyTask.

BaseTask carries both parent_id and project inherited by every task type, so both interpretations are structurally possible. The two views cannot both be correct:

If this change is right(PropertyTask.parent_id is an inventory item, only BatchTask.parent_id is a project): then the worker's PropertyTask mirror is actively wrong. It is stuffing an inventory id into the Project entity link. That mirror should be removed, not kept, and this is the correct fix for the BatchTask side.
If the worker is right (PropertyTask.parent_id is a project), then this change is incomplete (it should also mirror PropertyTask) and its docstring change is wrong.
I believe this needs confirmation from the task API owner or a real create test for both task types before merge

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirmed with @siddhant-albertinvent -- parentId is always project ID irrespective of task type.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, the tests are failing and they expect parent ID to be inventory ID for Property Tasks
cc: @siddhant-albertinvent

When a BatchTask is created with parent_id set but project omitted, the API
requires the Project entity in the request body for ACL resolution. Without
it the server crashes at runtime. Auto-populate Project from parent_id in
that case.

Also corrects the PropertyTask docstring: parent_id refers to the parent
inventory item, not a project.
parentId in the query param and Project.id in the payload must always
match, regardless of task type. Also reverts an incorrect PropertyTask
docstring edit (parent_id is the parent project, not inventory item).
@claude

claude Bot commented Jul 3, 2026

Copy link
Copy Markdown

Looks good - no bugs or correctness issues found.

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.

3 participants