home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.57k stars 30.74k forks source link

Github sensor isn’t created if 1 of the repos is incorrect/unavailable #31951

Closed Mariusthvdb closed 4 years ago

Mariusthvdb commented 4 years ago

The problem

using the GitHub sensor with an extensive list of tracked repos, the sensor isn't created at all, even if only 1 of the listed repos is incorrect/unavailable

Environment

Problem-relevant configuration.yaml

sensor:
  - platform: github
    access_token: !secret github_token
    entity_namespace: Github
    scan_interval: 3600
    repositories:
      - path: home-assistant/home-assistant
        name: Home-assistant
      - path: thomasloven/hass-browser_mod
        name: Browser mod
      - path: dnguyen800/air-visual-card
        name: Air visual
      - path: thomasloven/lovelace-auto-entities
        name: Auto entities
      - path: custom-cards/bar-card
        name: Bar
      - path: custom-cards/bignumber-card
        name: Big number
      - path: custom-cards/button-card
        name: Button
      - path: thomasloven/lovelace-card-mod
        name: Card mod
      - path: thomasloven/lovelace-card-tools
        name: Card tools
#      - path: custom-cards/config-template-card
#        name: Config template
      - path: maykar/custom-header
        name: Custom header
#      - path: iammexx/home-assistant-config/tree/master/ui/darksky
#        name: Darksky weather card
      - path: custom-cards/decluttering-card
        name: Decluttering
      - path: custom-cards/entity-attributes-card
        name: Entity attributes
      - path: thomasloven/lovelace-fold-entity-row
        name: Fold entity row
      - path: custom-cards/gauge-card
        name: Gauge
      - path: custom-cards/group-card
        name: Group
      - path: thomasloven/lovelace-layout-card
        name: Layout card
      - path: DBuit/light-popup-card
        name: Light popup
      - path: iantrich/list-card
        name: List
      - path: gadgetchnnel/lovelace-card-templater
        name: Card templater
      - path: kalkih/mini-graph-card
        name: Mini graph
      - path: kalkih/mini-media-player
        name: Mini media player
      - path: benct/lovelace-multiple-entity-row
        name: Multiple entity row
      - path: gurbyz/power-wheel-card
        name: Power wheel
      - path: iantrich/restriction-card
        name: Restriction
      - path: custom-cards/secondaryinfo-entity-row
        name: Secondary info row
      - path: kalkih/simple-weather-card
        name: Simple weather
      - path: thomasloven/lovelace-slider-entity-row
        name: Slider entity row
      - path: thomasloven/lovelace-state-switch
        name: State switch
#      - path: bramkragten/custom-ui/tree/master/swipe-card
#        name: Swipe
      - path: thomasloven/lovelace-template-entity-row
        name: Template entity row
#      - path: rodrigofragadf/lovelace-cards/tree/master/tiles-card
#        name: Tiles
      - path: thomasloven/lovelace-toggle-lock-entity-row
        name: Toggle lock entity row
      - path: ofekashery/vertical-stack-in-card
        name: Vertical stack in card
      - path: royto/waze-card
        name: Waze
      - path: sgttrs/lovelace-weather-card-chart
        name: Weather card chart

Traceback/Error logs

GitHub error for custom-cards/config-template-card: 401 {'message': 'Bad credentials', 'documentation_url': 'https://developer.github.com/v3'}

Additional information

any of the above commented repos cause the complete sensor to not being created/initiated. would expect the sensor to error on the given repo, and create the rest of the sensor.

more over, the GitHub error is about bad credentials, which is incorrect, but maybe out of control for the HA system. Please see if this sensor can isolate the incorrect repo, and continue building the rest.

tholgir commented 4 years ago

I just tested this issue and I get the same result. Any status other than 200 seems to trigger the exception. The text about bad credentials is either supplied by the pygithub package or the github api as this text is not present in the code for the sensor.

I'll try to see if I can find something to fix this issue seeing as I need my python practice.

Mariusthvdb commented 4 years ago

Thanks! Could you please check also why the first ( and copied directly from the documentation) homeassistant repo doesn’t work either? No error, but no sensor either ;-)

tholgir commented 4 years ago

If i use the following example from the integration page I get a sensor that works just fine for me

sensor:
  - platform: github
    access_token: removed
    repositories:
      - path: 'home-assistant/home-assistant'

If you have a invalid or moved repository in the list it does break the setup of valid repositories

Mariusthvdb commented 4 years ago

thanks for checking! and, well, I checked again too, and what do you know, the home assistant sensor is there after all, but it's the only one without the prefix (entity_namespace) Github, as Ive configured the full config posted above... How on earth is that possible?

Mariusthvdb commented 4 years ago

thanks @kuchel77 for the fix, much appreciated! hope we see it soon in the update