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.

Hi everyone!

@John_Vu i am having the same problem reported by @Wiktor_Jurek

Sometimes the method get_tasks_for_project returns the correct number of tasks, and sometimes it returns an empty list!! Do you have any update reggarding this issue?

Thanks in advance!

@John_Vu I don’t know why, but the problem is with the opt_fields when making the api call. This is a comparison between the api response considering just the name as opt_fields (left) and the api response considering all these opt_fields:

‘opt_fields’: ‘name,assignee.name,assignee.email,actual_time_minutes,due_on,created_at,projects.name,parent.name,parent.gid,completed,completed_at,tags.name,custom_fields.name,custom_fields.display_value,custom_fields.number_value,custom_fields.date_value’

Note that the number of returned tasks (tarefas) is very small when I add all the opt fields and it doesn’t reflect all the project tasks that it should return.

Hi @João_Valente, thank you for sharing your hypothesis and discovery. Can you try this again with one of the projects that have inconsistent results and making a call direct API call (e.g., using cURL) to our Get tasks from a project API endpoint. I want to narrow down the issue to see if this is python-asana client library issue or API issue.

Also, if you are able to setup a new project and reproduce this and provide us with the steps to reproduce on our end it would be helpful. I tried myself by could not reproduce. I might be doing something different in my setup than what you did.

1 Like