thegreenrobot / pagerduty_dashing

A Dashing dashboard for PagerDuty Services & Schedules
MIT License
44 stars 23 forks source link

No implicit conversion of nil into String #26

Closed d-zalewski closed 8 years ago

d-zalewski commented 8 years ago

I'm getting below when trying to start dashing with pagerduty widget enabled:

My Gemfile includes:

gem 'dashing' gem 'rest-client' gem 'faraday'

/usr/local/lib/ruby/2.0.0/json/common.rb:155:in `initialize': no implicit conversion of nil into String (TypeError)
        from /usr/local/lib/ruby/2.0.0/json/common.rb:155:in `new'
        from /usr/local/lib/ruby/2.0.0/json/common.rb:155:in `parse'
        from /var/www/html/ops_tv_dev/jobs/pagerduty_oncall.rb:7:in `<top (required)>'
        from /usr/local/lib/ruby/gems/2.0.0/gems/backports-3.6.7/lib/backports/std_lib.rb:9:in `require'
        from /usr/local/lib/ruby/gems/2.0.0/gems/backports-3.6.7/lib/backports/std_lib.rb:9:in `require_with_backports'
        from /usr/local/lib/ruby/gems/2.0.0/gems/dashing-1.3.4/lib/dashing/app.rb:157:in `block in require_glob'
        from /usr/local/lib/ruby/gems/2.0.0/gems/dashing-1.3.4/lib/dashing/app.rb:156:in `each'
        from /usr/local/lib/ruby/gems/2.0.0/gems/dashing-1.3.4/lib/dashing/app.rb:156:in `require_glob'
        from /usr/local/lib/ruby/gems/2.0.0/gems/dashing-1.3.4/lib/dashing/app.rb:167:in `<top (required)>'
        from /usr/local/lib/ruby/gems/2.0.0/gems/dashing-1.3.4/lib/dashing.rb:3:in `require'
        from /usr/local/lib/ruby/gems/2.0.0/gems/dashing-1.3.4/lib/dashing.rb:3:in `<top (required)>'
        from config.ru:1:in `require'
        from config.ru:1:in `block in <main>'
        from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.5.5/lib/rack/builder.rb:55:in `instance_eval'
        from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.5.5/lib/rack/builder.rb:55:in `initialize'
        from config.ru:1:in `new'
        from config.ru:1:in `<main>'
        from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.6.4/lib/rack/adapter/loader.rb:33:in `eval'
        from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.6.4/lib/rack/adapter/loader.rb:33:in `load'
        from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.6.4/lib/thin/controllers/controller.rb:182:in `load_rackup_config'
        from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.6.4/lib/thin/controllers/controller.rb:72:in `start'
        from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.6.4/lib/thin/runner.rb:200:in `run_command'
        from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.6.4/lib/thin/runner.rb:156:in `run!'
        from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.6.4/bin/thin:6:in `<top (required)>'
        from /usr/local/bin/thin:23:in `load'
        from /usr/local/bin/thin:23:in `<main>'
thegreenrobot commented 8 years ago

Hi there,

Sorry to hear about your troubles. Based on that error message, it's pointing to https://github.com/thegreenrobot/pagerduty_dashing/blob/master/jobs/pagerduty_oncall.rb#L7.

Do you have a environment variable with your PagerDuty schedules?

d-zalewski commented 8 years ago

Hi,

I have below in pagerduty_oncall.rb

env_schedules = ENV['Infrastructure - Primary on call rota']

thegreenrobot commented 8 years ago

Hi there,

As noted in the README, the environment variable for the schedules should like this:

{"schedules": { "oncall": "ABC1234","firefighter": "QAZ4567"}}
d-zalewski commented 8 years ago

I've tried below and still no luck. Does the value have to be id not the name?

"PAGERDUTY_SCHEDULES": "{"schedules": { "oncall": "Infrastructure - Primary on call rota"}}"

When I query pagerduty API directly I'm getting:

{
    "limit": 100,
    "offset": 0,
    "schedules": [
        {
            "description": "",
            "escalation_policies": [
                {
                    "id": "XXXXXXX",
                    "name": "Infrastructure - Escalation policy"
                }
            ],
            "id": "XXXXXXX",
            "name": "Infrastructure - Primary on call rota",
            "time_zone": "XXXXXXX",
            "today": "2016-03-02"
        },
        {
            "description": "",
            "escalation_policies": [
                {
                    "id": "XXXXXXX",
                    "name": "Infrastructure - Escalation policy"
                }
            ],
            "id": "XXXXXXX",
            "name": "Infrastructure - Secondary on call rota",
            "time_zone": "XXXXXXX",
            "today": "2016-03-02"
        }
    ],
    "total": 2
}
thegreenrobot commented 8 years ago

Hi there,

It needs to be the actual id of the schedule, you're giving it the name.

The oncall job is making a call to https://developer.pagerduty.com/documentation/rest/schedules/entries in https://github.com/thegreenrobot/pagerduty_dashing/blob/master/jobs/pagerduty_oncall.rb#L26

d-zalewski commented 8 years ago

Sorry for being a pain but IDs aren't working too. Probably something with my json...

"PAGERDUTY_SCHEDULES": "{"schedules": { "oncall": "PIH8XXX","firefighter": "P78PXXX"}}"

thegreenrobot commented 8 years ago

Are you trying to deploy this to Heroku using the push button?

If yes the value of the PAGERDUTY_SCHEDULES field just needs to be {"schedules": { "oncall": "ABC1234","firefighter": "QAZ4567"}}

Also, I just deployed to Heroku using the push button yesterday and all was well.

d-zalewski commented 8 years ago

I don't use Heroku. Just copied pagerduty_oncall.rb into jobs folder in my dashing dashboard and app.json where vars are set to the dashboard folder. I've tried cloning the whole repo and starting dashing from there and getting same problem.

srv1:root:/var/www/html/ops_tv_dev> ll dashboards/pagerduty.erb
-rw-rw-r--. 1 root root 2072 Mar  1 10:52 dashboards/pagerduty.erb

srv1:root:/var/www/html/ops_tv_dev> ll app.json
-rw-rw-r--. 1 root root 578 Mar  2 14:37 app.json

I've added below to my custom dashboard:

<li data-row="2" data-col="3" data-sizex="1" data-sizey="1">
      <div data-id="oncall-name" data-view="Text" data-title="Primary Oncall" data-moreinfo="Fix all the incidents!"</div>
   </li>
thegreenrobot commented 8 years ago

The code as is, assumes that you are going to deploy to Heroku and that's what the app.json is for.

The incidents and oncall jobs take PagerDuty configuration data via environment variables. You could very easily change the code locally to read the PagerDuty variables from a local file (json) or set your own environment variables.

I know that is possible b/c I used to run this on a server (not Heroku) and all of the PagerDuty variables were defined in a json file.

d-zalewski commented 8 years ago

My bad. I corrected environments and its all working fine now.

Thanks for help!