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

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

Open
1 task done
ErikOwen opened this issue Apr 27, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@ErikOwen
Copy link

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

@ErikOwen ErikOwen added the bug Something isn't working label Apr 27, 2023
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