Skip to content

Fix invalid return when encountering malformed data

Igor Frenkel requested to merge ifrenkel-fix-nil-return-when-csv-error into master

What does this MR do and why?

This MR resolves a bug where the caller to DataObject.from_csv expects either a nil or a DataObject. But the way the rescue is currently done, the caller gets a true:TrueClass from the logger. This breaks the result contract with callers.

How to set up and validate locally

bundle exec rails console

text_causing_csv_exception='sndfileio,\"0.6\n' # you can check the exception thrown by running CSV.parse_line(text_causing_csv_exception)
puts PackageMetadata::DataObject.from_csv(text_causing_csv_exception, 'composer')                                                                                                                      
# returns nil

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports