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

400 Bad Request when trying to share results via SHARE=true skunk lib/ #13

Closed
etagwerker opened this issue Nov 13, 2020 · 1 comment · Fixed by #15
Closed

400 Bad Request when trying to share results via SHARE=true skunk lib/ #13

etagwerker opened this issue Nov 13, 2020 · 1 comment · Fixed by #15
Assignees

Comments

@etagwerker
Copy link
Member

I'm currently getting an error when trying to use the feature proposed here: fastruby/skunk#56

Started POST "/reports" for ::1 at 2020-11-13 11:59:51 -0500
Processing by ReportsController#create as */*
  Parameters: {"{\"entries\":\" ----------------------------------------------------- ---------------- ------------------ -------------- -------------- -------------- \\n| file                                                | skunk_score    | churn_times_cost | churn        | cost         | coverage     |\\n ----------------------------------------------------- ---------------- ------------------ -------------- -------------- -------------- \\n| lib/skunk/share.rb                                  | 115.68         | 1.16             | 1            | 1.16         | 0.0          |\\n| lib/skunk/cli/commands/compare_score.rb             | 62.8           | 1.26             | 2            | 0.63         | 0.0          |\\n| lib/skunk/cli/commands/compare.rb                   | 26.4           | 20.74            | 11           | 1.89         | 86.36        |\\n| lib/skunk/cli/options/argv.rb                       | 16.33          | 8.98             | 11           | 0.82         | 80.95        |\\n| lib/skunk/cli/commands/status_reporter.rb           | 8.96           | 47.78            | 16           | 2.99         | 97.44        |\\n| lib/skunk/cli/commands/version.rb                   | 8.8            | 0.44             | 5            | 0.09         | 0.0          |\\n| lib/skunk/cli/command_factory.rb                    | 8.3            | 1.46             | 3            | 0.49         | 83.33        |\\n| lib/skunk/cli/application.rb                        | 6.86           | 16.67            | 17           | 0.98         | 93.1         |\\n| lib/skunk/rubycritic/analysed_modules_collection.rb | 4.96           | 1.52             | 4            | 0.38         | 87.5         |\\n| lib/skunk/cli/commands/base.rb                      | 2.26           | 0.3              | 3            | 0.1          | 77.78        |\\n| lib/skunk/rubycritic/analysed_module.rb             | 0.93           | 7.43             | 8            | 0.93         | 100.0        |\\n| lib/skunk/cli/options.rb                            | 0.68           | 6.8              | 10           | 0.68         | 100.0        |\\n| lib/skunk/cli/commands/default.rb                   | 0.63           | 3.17             | 5            | 0.63         | 100.0        |\\n| lib/skunk/cli/commands/output.rb                    | 0.09           | 0.09             | 1            | 0.09         | 100.0        |\\n| lib/skunk/version.rb                                | 0.0            | 0.0              | 9            | 0.0          | 0.0          |\\n| lib/skunk/cli/commands/help.rb                      | 0.0            | 0.0              | 3            | 0.0          | 100.0        |\\n| lib/skunk.rb                                        | 0.0            | 0.0              | 4            | 0.0          | 100.0        |\\n ----------------------------------------------------- ---------------- ------------------ -------------- -------------- -------------- \\n\\nSkunkScore Total: 263.68\\nModules Analysed: 17\\nSkunkScore Average: 15.51\\nWorst SkunkScore: 115.68 (lib/skunk/share.rb)\\n\\nGenerated with Skunk v0.4.2\\n\",\"options\":{\"compare\":\"false\"}}"=>nil}
Completed 400 Bad Request in 0ms (ActiveRecord: 0.0ms | Allocations: 105)
@etagwerker etagwerker self-assigned this Nov 13, 2020
@etagwerker
Copy link
Member Author

The problem is related to the entries not being an array but a string. More details here:

[7, 16] in /Users/etagwerker/Projects/fastruby/skunk.fyi/app/controllers/reports_controller.rb
    7:
    8:   def create
    9:     data = request.body.read
   10:     byebug
   11:     begin
=> 12:       input = JSON.parse data
   13:     rescue Exception => err
   14:       logger.fatal("Error: #{err.message} || #{data}")
   15:       head 400
   16:       return
(byebug) data
"{\"entries\":\"+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\\n| file                                                | skunk_score    | churn_times_cost | churn        | cost         | coverage     |\\n+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\\n| lib/skunk/share.rb                                  | 115.68         | 1.16             | 1            | 1.16         | 0.0          |\\n| lib/skunk/cli/commands/compare_score.rb             | 62.8           | 1.26             | 2            | 0.63         | 0.0          |\\n| lib/skunk/cli/commands/compare.rb                   | 26.4           | 20.74            | 11           | 1.89         | 86.36        |\\n| lib/skunk/cli/options/argv.rb                       | 16.33          | 8.98             | 11           | 0.82         | 80.95        |\\n| lib/skunk/cli/commands/status_reporter.rb           | 8.96           | 47.78            | 16           | 2.99         | 97.44        |\\n| lib/skunk/cli/commands/version.rb                   | 8.8            | 0.44             | 5            | 0.09         | 0.0          |\\n| lib/skunk/cli/command_factory.rb                    | 8.3            | 1.46             | 3            | 0.49         | 83.33        |\\n| lib/skunk/cli/application.rb                        | 6.86           | 16.67            | 17           | 0.98         | 93.1         |\\n| lib/skunk/rubycritic/analysed_modules_collection.rb | 4.96           | 1.52             | 4            | 0.38         | 87.5         |\\n| lib/skunk/cli/commands/base.rb                      | 2.26           | 0.3              | 3            | 0.1          | 77.78        |\\n| lib/skunk/rubycritic/analysed_module.rb             | 0.93           | 7.43             | 8            | 0.93         | 100.0        |\\n| lib/skunk/cli/options.rb                            | 0.68           | 6.8              | 10           | 0.68         | 100.0        |\\n| lib/skunk/cli/commands/default.rb                   | 0.63           | 3.17             | 5            | 0.63         | 100.0        |\\n| lib/skunk/cli/commands/output.rb                    | 0.09           | 0.09             | 1            | 0.09         | 100.0        |\\n| lib/skunk/version.rb                                | 0.0            | 0.0              | 9            | 0.0          | 0.0          |\\n| lib/skunk/cli/commands/help.rb                      | 0.0            | 0.0              | 3            | 0.0          | 100.0        |\\n| lib/skunk.rb                                        | 0.0            | 0.0              | 4            | 0.0          | 100.0        |\\n+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\\n\\nSkunkScore Total: 263.68\\nModules Analysed: 17\\nSkunkScore Average: 15.51\\nWorst SkunkScore: 115.68 (lib/skunk/share.rb)\\n\\nGenerated with Skunk v0.4.2\\n\",\"options\":{\"compare\":\"false\"}}"
(byebug) JSON.parse data
{"entries"=>"+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\n| file                                                | skunk_score    | churn_times_cost | churn        | cost         | coverage     |\n+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\n| lib/skunk/share.rb                                  | 115.68         | 1.16             | 1            | 1.16         | 0.0          |\n| lib/skunk/cli/commands/compare_score.rb             | 62.8           | 1.26             | 2            | 0.63         | 0.0          |\n| lib/skunk/cli/commands/compare.rb                   | 26.4           | 20.74            | 11           | 1.89         | 86.36        |\n| lib/skunk/cli/options/argv.rb                       | 16.33          | 8.98             | 11           | 0.82         | 80.95        |\n| lib/skunk/cli/commands/status_reporter.rb           | 8.96           | 47.78            | 16           | 2.99         | 97.44        |\n| lib/skunk/cli/commands/version.rb                   | 8.8            | 0.44             | 5            | 0.09         | 0.0          |\n| lib/skunk/cli/command_factory.rb                    | 8.3            | 1.46             | 3            | 0.49         | 83.33        |\n| lib/skunk/cli/application.rb                        | 6.86           | 16.67            | 17           | 0.98         | 93.1         |\n| lib/skunk/rubycritic/analysed_modules_collection.rb | 4.96           | 1.52             | 4            | 0.38         | 87.5         |\n| lib/skunk/cli/commands/base.rb                      | 2.26           | 0.3              | 3            | 0.1          | 77.78        |\n| lib/skunk/rubycritic/analysed_module.rb             | 0.93           | 7.43             | 8            | 0.93         | 100.0        |\n| lib/skunk/cli/options.rb                            | 0.68           | 6.8              | 10           | 0.68         | 100.0        |\n| lib/skunk/cli/commands/default.rb                   | 0.63           | 3.17             | 5            | 0.63         | 100.0        |\n| lib/skunk/cli/commands/output.rb                    | 0.09           | 0.09             | 1            | 0.09         | 100.0        |\n| lib/skunk/version.rb                                | 0.0            | 0.0              | 9            | 0.0          | 0.0          |\n| lib/skunk/cli/commands/help.rb                      | 0.0            | 0.0              | 3            | 0.0          | 100.0        |\n| lib/skunk.rb                                        | 0.0            | 0.0              | 4            | 0.0          | 100.0        |\n+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\n\nSkunkScore Total: 263.68\nModules Analysed: 17\nSkunkScore Average: 15.51\nWorst SkunkScore: 115.68 (lib/skunk/share.rb)\n\nGenerated with Skunk v0.4.2\n", "options"=>{"compare"=>"false"}}
(byebug) next

[14, 23] in /Users/etagwerker/Projects/fastruby/skunk.fyi/app/controllers/reports_controller.rb
   14:       logger.fatal("Error: #{err.message} || #{data}")
   15:       head 400
   16:       return
   17:     end
   18:
=> 19:     ary = input["entries"]
   20:
   21:     unless ary.kind_of? Array
   22:       head 400
   23:       return
(byebug) input
{"entries"=>"+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\n| file                                                | skunk_score    | churn_times_cost | churn        | cost         | coverage     |\n+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\n| lib/skunk/share.rb                                  | 115.68         | 1.16             | 1            | 1.16         | 0.0          |\n| lib/skunk/cli/commands/compare_score.rb             | 62.8           | 1.26             | 2            | 0.63         | 0.0          |\n| lib/skunk/cli/commands/compare.rb                   | 26.4           | 20.74            | 11           | 1.89         | 86.36        |\n| lib/skunk/cli/options/argv.rb                       | 16.33          | 8.98             | 11           | 0.82         | 80.95        |\n| lib/skunk/cli/commands/status_reporter.rb           | 8.96           | 47.78            | 16           | 2.99         | 97.44        |\n| lib/skunk/cli/commands/version.rb                   | 8.8            | 0.44             | 5            | 0.09         | 0.0          |\n| lib/skunk/cli/command_factory.rb                    | 8.3            | 1.46             | 3            | 0.49         | 83.33        |\n| lib/skunk/cli/application.rb                        | 6.86           | 16.67            | 17           | 0.98         | 93.1         |\n| lib/skunk/rubycritic/analysed_modules_collection.rb | 4.96           | 1.52             | 4            | 0.38         | 87.5         |\n| lib/skunk/cli/commands/base.rb                      | 2.26           | 0.3              | 3            | 0.1          | 77.78        |\n| lib/skunk/rubycritic/analysed_module.rb             | 0.93           | 7.43             | 8            | 0.93         | 100.0        |\n| lib/skunk/cli/options.rb                            | 0.68           | 6.8              | 10           | 0.68         | 100.0        |\n| lib/skunk/cli/commands/default.rb                   | 0.63           | 3.17             | 5            | 0.63         | 100.0        |\n| lib/skunk/cli/commands/output.rb                    | 0.09           | 0.09             | 1            | 0.09         | 100.0        |\n| lib/skunk/version.rb                                | 0.0            | 0.0              | 9            | 0.0          | 0.0          |\n| lib/skunk/cli/commands/help.rb                      | 0.0            | 0.0              | 3            | 0.0          | 100.0        |\n| lib/skunk.rb                                        | 0.0            | 0.0              | 4            | 0.0          | 100.0        |\n+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\n\nSkunkScore Total: 263.68\nModules Analysed: 17\nSkunkScore Average: 15.51\nWorst SkunkScore: 115.68 (lib/skunk/share.rb)\n\nGenerated with Skunk v0.4.2\n", "options"=>{"compare"=>"false"}}
(byebug) next

[16, 25] in /Users/etagwerker/Projects/fastruby/skunk.fyi/app/controllers/reports_controller.rb
   16:       return
   17:     end
   18:
   19:     ary = input["entries"]
   20:
=> 21:     unless ary.kind_of? Array
   22:       head 400
   23:       return
   24:     end
   25:
(byebug) ary
"+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\n| file                                                | skunk_score    | churn_times_cost | churn        | cost         | coverage     |\n+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\n| lib/skunk/share.rb                                  | 115.68         | 1.16             | 1            | 1.16         | 0.0          |\n| lib/skunk/cli/commands/compare_score.rb             | 62.8           | 1.26             | 2            | 0.63         | 0.0          |\n| lib/skunk/cli/commands/compare.rb                   | 26.4           | 20.74            | 11           | 1.89         | 86.36        |\n| lib/skunk/cli/options/argv.rb                       | 16.33          | 8.98             | 11           | 0.82         | 80.95        |\n| lib/skunk/cli/commands/status_reporter.rb           | 8.96           | 47.78            | 16           | 2.99         | 97.44        |\n| lib/skunk/cli/commands/version.rb                   | 8.8            | 0.44             | 5            | 0.09         | 0.0          |\n| lib/skunk/cli/command_factory.rb                    | 8.3            | 1.46             | 3            | 0.49         | 83.33        |\n| lib/skunk/cli/application.rb                        | 6.86           | 16.67            | 17           | 0.98         | 93.1         |\n| lib/skunk/rubycritic/analysed_modules_collection.rb | 4.96           | 1.52             | 4            | 0.38         | 87.5         |\n| lib/skunk/cli/commands/base.rb                      | 2.26           | 0.3              | 3            | 0.1          | 77.78        |\n| lib/skunk/rubycritic/analysed_module.rb             | 0.93           | 7.43             | 8            | 0.93         | 100.0        |\n| lib/skunk/cli/options.rb                            | 0.68           | 6.8              | 10           | 0.68         | 100.0        |\n| lib/skunk/cli/commands/default.rb                   | 0.63           | 3.17             | 5            | 0.63         | 100.0        |\n| lib/skunk/cli/commands/output.rb                    | 0.09           | 0.09             | 1            | 0.09         | 100.0        |\n| lib/skunk/version.rb                                | 0.0            | 0.0              | 9            | 0.0          | 0.0          |\n| lib/skunk/cli/commands/help.rb                      | 0.0            | 0.0              | 3            | 0.0          | 100.0        |\n| lib/skunk.rb                                        | 0.0            | 0.0              | 4            | 0.0          | 100.0        |\n+-----------------------------------------------------+----------------+------------------+--------------+--------------+--------------+\n\nSkunkScore Total: 263.68\nModules Analysed: 17\nSkunkScore Average: 15.51\nWorst SkunkScore: 115.68 (lib/skunk/share.rb)\n\nGenerated with Skunk v0.4.2\n"
(byebug) ary.kind_of? Array
false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant