newrelic / nr1-github

NR1 Github allows you to create more context to your entities by having access to the GitHub repository, contributors and README.
https://github.com/newrelic/nr1-github/discussions
Apache License 2.0
18 stars 27 forks source link

On setup, when "Error fetching suggestions", the "Provide your own repository URL" doesn't appear #26

Closed joelbeckham closed 4 years ago

joelbeckham commented 4 years ago

Description

When my APM service has a unique name that doesn't return anything from the GitHub suggestion search, the "Provide your own repository URL" field doesn't appear, so I can't manually configure it.

Steps to Reproduce

  1. Go to the Entity Explorer.
  2. Click on an APM Service that has a very unique name, such as "PROD-Bixel-NewLH",
  3. Go to the GitHub Repo app
  4. Go to the Repository Tab
  5. I get a "An error occurred: Error fetching suggestions" and no "Provide your own repository URL".

Expected Behaviour

"Provide your own repository URL" field should appear even if no suggestions are found.

Relevant Logs / Console output

I can see the network request to github: https://api.github.com/search/repositories?q=in%3Aname%20in%3Areadme%20in%3Adescription%20PROD%20Bixel-NewLH

It returns a 200 with this response:

{
  "total_count": 0,
  "incomplete_results": false,
  "items": [
  ]
}

Your Environment

I installed this via the "Application Catalog" app on the New Relic ONE dashboard and not through the CLI.

It says that it's: Release date: January 15, 2020 Version 0.4.0

Additional context

On the master branch in https://github.com/newrelic/nr1-github/blob/master/nerdlets/github-about/repo-picker.js, the render function returns if there is an error:

    if (error) {
      return (
        <>
          <h2>An error occurred:</h2>
          <p>{error}</p>
        </>
      );
    }

So it never renders the this.renderSuggestions() which handles the custom url field (this.renderCustomUrlRow())

    return (
      <Stack directionType="vertical" alignmentType="fill">
        <StackItem>{this.renderSuggestions()}</StackItem>
      </Stack>
    );

If no suggestions are found, that's an error condition in loadSuggestions():

    github.get(path).then(suggestions => {
      if (suggestions.items && suggestions.items.length > 0) {
        this.setState({ suggestions: suggestions.items });
        return;
      }
      this.setState({ error: 'Error fetching suggestions' });
    });
danielgolden commented 4 years ago

Thanks a ton for the issue, @joelbeckham! Just submitted a PR to fix this.