Skip to content

[BUG]: Exception Raised When Getting Dependency Graph for Project That Isn't Using a Supported Package Manager #173

@ErikOwen

Description

@ErikOwen

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

I was using the pysnyk package to pull a dependency graph for a project that had a project type of dockerfile, and it raised this exception:

ValueError: Argument for snyk.models.DependencyGraph.from_dict method should be a dict instance

This exception isn't intuitive, and at first glance it appears that the Snyk SDK wasn't compatible with the response from the Snyk API.

I raised a ticket with Snyk support, and I was told that the reason the exception was being raised was because the dependency graph API endpoint only supports specific package managers (see here).

The Snyk API should raise a more helpful exception to help end users understand that the project they are trying to get the dependency graph for isn't currently supported.

Steps To Reproduce

import snyk # from https://pypi.org/project/pysnyk/
snyk_client = snyk.SnykClient("<put-snyk-api-token-here>")
org = snyk_client.organizations.get("<put-org-id-with-project-that-has-dockerfile-as-type>")
[p.dependency_graph for p in org.projects.all()]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <listcomp>
  File "/Path/to/virtual_env/.venv/lib/python3.9/site-packages/snyk/models.py", line 647, in dependency_graph
    return Manager.factory(DependencyGraph, self.organization.client, self).all()
  File "/Path/to/virtual_env/.venv/lib/python3.9/site-packages/snyk/managers.py", line 377, in all
    return self.klass.from_dict(dependency_data["depGraph"])
  File "<string>", line 43, in from_dict
ValueError: Argument for snyk.models.DependencyGraph.from_dict method should be a dict instance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions