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

fix: KeyError in format_data function #3452

Merged
merged 7 commits into from
Nov 2, 2023
Merged

Conversation

joydeep049
Copy link
Contributor

This pull request addresses a KeyError issue in the format_data function. The function was encountering a KeyError when attempting to access the package key in certain cases. To resolve this issue, a check has been added to ensure that the package key exists before attempting to access its contents. This modification ensures that the function can handle cases where the package key is missing or empty, preventing the KeyError.

Additionally, this change includes minor formatting improvements for better readability and consistency.

This fix has been thoroughly tested and ensures the reliable execution of the format_data function, enhancing its robustness.

Please review and merge at your earliest convenience. Thank you!

Debugged the code based on a basic problem that I faced while installing cve-bin-tool
@codecov-commenter
Copy link

codecov-commenter commented Oct 23, 2023

Codecov Report

Merging #3452 (171f7e1) into main (c0c9889) will decrease coverage by 0.51%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##             main    #3452      +/-   ##
==========================================
- Coverage   78.56%   78.05%   -0.51%     
==========================================
  Files         758      758              
  Lines       11484    11487       +3     
  Branches     1342     1343       +1     
==========================================
- Hits         9022     8966      -56     
- Misses       2038     2096      +58     
- Partials      424      425       +1     
Flag Coverage Δ
win-longtests 78.05% <50.00%> (-0.51%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
cve_bin_tool/data_sources/osv_source.py 57.91% <50.00%> (-26.49%) ⬇️

... and 5 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@terriko terriko changed the title Fix KeyError in format_data function fix: KeyError in format_data function Oct 24, 2023
Copy link
Contributor

@terriko terriko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

I've got a couple of nitpicks for the linters; I've marked them as suggestions but I'm going to merge them now and let the linters run again.

cve_bin_tool/data_sources/osv_source.py Outdated Show resolved Hide resolved
cve_bin_tool/data_sources/osv_source.py Fixed Show resolved Hide resolved
cve_bin_tool/data_sources/osv_source.py Outdated Show resolved Hide resolved
cve_bin_tool/data_sources/osv_source.py Dismissed Show dismissed Hide dismissed
Copy link
Contributor

@terriko terriko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't merge this while it's still failing black and flake8 checks, but this is close enough to ready that i'm going to mark it as approved for hacktoberfest in case you need the credit. Please fix the linter issues when you get a chance, or if they're too much let me know and I'll try to resolve them for you later in the week.

@terriko terriko added awaiting submitter Need more information from submitter HACKTOBERFEST-ACCEPTED and removed awaiting CI labels Nov 1, 2023
@joydeep049

This comment was marked as resolved.

@terriko terriko added awaiting CI and removed awaiting submitter Need more information from submitter labels Nov 1, 2023
@joydeep049
Copy link
Contributor Author

When I ran it locally on my machine it passed all the pre-commit hook tests. I'm stuck.
Uploading Screenshot (262).png…

Copy link
Contributor

@terriko terriko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to see if I can fix the issues reported manually since they look pretty simple to do:

 cve_bin_tool/data_sources/osv_source.py:302:30: E261 at least two spaces before inline comment
cve_bin_tool/data_sources/osv_source.py:303:18: W291 trailing whitespace

I'll merge these and let the tests re-run.

cve_bin_tool/data_sources/osv_source.py Outdated Show resolved Hide resolved
cve_bin_tool/data_sources/osv_source.py Outdated Show resolved Hide resolved
@terriko terriko added awaiting maintainer Need a maintainer to respond / help out and removed awaiting CI labels Nov 2, 2023
Copy link
Contributor

@terriko terriko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

black issues have been resolved manually by me, so this is ready to merge. Thank you and happy hacktoberfest!

@terriko terriko merged commit 4747248 into intel:main Nov 2, 2023
21 checks passed
@joydeep049 joydeep049 deleted the my-branch branch November 3, 2023 17:07
terriko added a commit to terriko/cve-bin-tool that referenced this pull request Nov 16, 2023
* Update osv_source.py

Debugged the code based on a basic problem that I faced while installing cve-bin-tool

* fix: flake8 and codeql tweaks

* chore: blacken cve_bin_tool/data_sources/osv_source.py

---------

Co-authored-by: Terri Oda <terri.oda@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting maintainer Need a maintainer to respond / help out HACKTOBERFEST-ACCEPTED
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants