Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK methods that list child objects don't always work when the parent object is in an organization #8914

Open
2 tasks done
SpecLad opened this issue Jan 9, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@SpecLad
Copy link
Contributor

SpecLad commented Jan 9, 2025

Actions before raising this issue

  • I searched the existing issues and did not find anything similar.
  • I read/searched the docs

Steps to Reproduce

  1. Create two accounts, user1 and user2.

  2. Create an organization as user1, and add user2 as a maintainer.

  3. Create a project in the organization as user1.

  4. Create a task in the project as user1.

  5. Create the following script:

    import os
    import sys
    
    from cvat_sdk import make_client
    
    def main():
        proj_id = int(sys.argv[1])
    
        with make_client(
            host="http://localhost:8080",
            credentials=(os.environ["CVAT_AI_USER"], os.environ["CVAT_AI_PASS"])
        ) as client:
            project = client.projects.retrieve(proj_id)
    
            for task in project.get_tasks():
                print(task.id)
    
    main()
  6. Run the script with user2's credentials, passing the ID of the project. It prints nothing.

Expected Behavior

The script should print the ID of the task.

By comparison, if you run the script with user1's credentials, this does happen.

Possible Solution

We should probably make the SDK override the current organization while making the "list tasks" request, if the project is in an organization.

Alternatively, we could alter the server's response to list all tasks that the user has access to, regardless of what organization they are in.

Context

I believe this affects all SDK methods that list child objects of some other objects, although I haven't tested them all. These methods are:

Issue.get_comments
Job.get_labels
Job.get_issues
Project.get_tasks
Project.get_labels
Task.get_jobs
Task.get_labels

Environment

Reproducible with commit b594b1c.

@SpecLad SpecLad added the bug Something isn't working label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant