Issue with get_tasks_for_project Returning Inconsistent Results

Hi all,

I’m running into an issue with the tasks_api_instance.get_tasks_for_project function in the Python Asana API (version 5.0.11). When I call this function, it sometimes returns the correct number of tasks, but other times it returns 0 tasks, even though I know there are tasks in the project. Here are some additional details:

  • Authentication: I’m using a service account access token.
  • Code: Here’s a snippet of the code that’s giving me trouble:
opts = {
    'opt_fields': ",".join(fields),
    'limit': 100,
}

for project in project_array:
    tasks_array = list(tasks_api_instance.get_tasks_for_project(
        project["gid"], opts=opts))
    yield tasks_array
  • Fields Requested: These are the fields I’m requesting for each task:
fields = (
    "gid", "resource_type", "name", "approval_status", "assignee_status",
    "created_at", "assignee", "start_on", "start_at", "due_on", "due_at",
    "completed", "completed_at", "completed_by", "modified_at",
    "dependencies", "dependents", "external", "notes", "num_subtasks",
    "resource_subtype", "followers", "parent", "permalink_url", "tags",
    "workspace", "custom_fields", "project", "memberships",
    "memberships.project.name", "memberships.section.name",
)

I’ve looked at

  • This post, but they’re using nodejs and resolved it by using the paid plan. We’re on Enterprise Legacy.
  • This post, and it seems there’s a bug when asking for paginated results, but I’m getting issues with both paginated and unpaginated.

Has anyone encountered similar inconsistencies with this function? Could it be an issue with the way pagination is handled, or are there any known limitations with the service account token and accessing tasks across projects?

Thanks for any insights!

Hi @Wiktor_Jurek,

are there any known limitations with the service account token and accessing tasks across projects

Not that I know of. If anything, it should have more permissions than a regular Personal Access Token (PAT).

Are you still experiencing this issue?

I tried to reproduce this issue by:

  1. Creating a project with multiple sections (e.g., 3 sections)
  2. Adding tasks to the sections in the projects (e.g., 7 tasks)
  3. Generated a Service Account Token
  4. Made an API call to the Get tasks from a project endpoint both via Postman and the python-asana client library (v5.0.10 and v5.0.11) changing the limit query param from 1-10 than tried query limit 100
  5. Did not run into the same issue as you did

Also, note that pagination is handled by default with the python-asana client library so you do not need to provide a limit query param. When you provide a limit query param what it does is change how the python client makes API calls to Asana. By default, the query limit is 100 if you don’t specify anything if you specify 5 for example in the background the python client will make API calls with page limits of 5 and stitch them together into a paginated result.

Could you please try testing again to see if the issue persists? If you still encounter the problem, could you provide additional details about your setup? This will help us reproduce and troubleshoot the issue more effectively.

Just an update for the team - I’ve still got this issue. I’ve decided to use the search API for the time being, and that’s successfully getting all of the tasks.

Thanks,

Hi @Wiktor_Jurek, thanks for reporting back with a workaround. We’ll keep an eye out on this post if anyone else runs into this issue.