New to Nerd Packs... encountering 403 error with EntitiesByDomainTypeQuery

I’m new to building Nerd Packs and have been encountering an issue trying to load some entity information into one of my learning/testing packs… the entity is:

    <StackItem className="container">
        <EntitiesByDomainTypeQuery entityDomain="BROWSER" entityType="APPLICATION">
        {({loading, error, data}) => {
            console.debug([loading, data, error]); //eslint-disable-line

            if (loading) {
                return <Spinner/>;
            }
            if (error) {
                return <BlockText>{JSON.stringify(error)}</BlockText>;
            }
            return <Fragment>
                <HeadingText>Entity by Domain Type</HeadingText>
                {this._renderTable(data.entities)}
            </Fragment>
        }}
        </EntitiesByDomainTypeQuery>
    </StackItem>

This is what I see:

Any idea why I’m getting 403s? I have API and admin keys set for every New Relic account. I should also mention the example I took this from doesn’t seem to work either. I don’t have any issues running NRQL but can’t seem to get any of the entities to load.

Just to add to the mystery… it’s not just these entities but making any kind of graphql call:

componentDidMount(){
    const accountId = this.state;
    const gql = `{ actor { accounts { id name } } }`;

    const accounts = NerdGraphQuery.query({query: gql})
    accounts.then(results => {
        console.log('Nerdgraph Response:', results);
		**console.debug(JSON.stringify(accounts))**
        const accounts = results.data.actor.accounts.map(account => {
            return account;
        });
        const account = accounts.length > 0 && accounts[0];
        this.setState({ selectedAccount: account, accounts });
    }).catch((error) => { console.log('Nerdgraph Error:', error); })
}

It seems like I must be missing something pretty fundamental here…:

These are all the imports:

import React from 'react';
import {
  PlatformStateContext,
  NerdGraphQuery,
  Grid,
  GridItem,
  Stack,
  StackItem,
  Dropdown,
  DropdownItem,
  TextField,
  Button,

  EntityByGuidQuery, 
  EntitiesByNameQuery, 
  EntitiesByDomainTypeQuery, 
  EntityCountQuery, 
  Spinner, 
  HeadingText, 
  BlockText, 
  NerdletStateContext,
  Select,
  SelectItem  
} from 'nr1';

Can you try this from the command line and restart?

nr1 nerdpack:uuid -gf

the new uuid will hopefully give you proper permissions with this nerdGraph query. I’m pretty sure @RyanVeitch can point you to more documentation explaining why/how etc.

1 Like

Weird, I think this fixed it… I’m pretty sure I had done this before (and looking at the command line history I see it there). Does this need to be run every time before serving the Nerdpack?

It shouldn’t need to be run every time. Is it possible that you had previously run the uuid -gf command in a different project? Or, had you previously run that command in the context of a different NR1 profile?

The UUID is unique to the project it belongs to, and it is generated using the NR1 profile you are working from.

The error you were receiving was 403, which implies forbidden permission errors.

Hence the guess here that you had generated the UUID from a different profile, or, in a different project. Such that the UUID for the project you are currently serving isn’t associated with the profile that is serving it.

I’m not sure what the root cause was but I was working with a lot of apps at the time, so possible I didn’t generate a UUID. Thanks for the help, seems working now.

Also, just throwing this out there… but is there any reason you shouldn’t use this command when serving the Nerdpack? If it’s required every time is there any reason it doesn’t just run automatically?

Hey @Michael.Sleep

So regenerating the UUID is not required every time you serve locally. There is little harm in doing so if you are just running locally, however the difficulty then comes when you are working on a local version of an app that is also deployed to your accounts.

If you have a version of your nerdpack deployed and subscribed to your accounts (such that it is available to all users without locally serving), and you also have that same nerdpack locally for you to continue to develop, then when it comes time to push updates to the app, you will need to deploy it using the same UUID as the already deployed nerdpack. Otherwise it’ll show up twice in the New Relic One UI (one with the old UUID, one with the new).

Because of that reason, its not advised that you regen the UUID every time you locally serve.

Note that the regen command is run automatically in some cases though.

If you pull a nerdpack from github with the following command:

nr1 nerdpack:clone -r https://github.com/newrelic/nr1-nerdpack.git

then the NR1 CLI tool will automatically run the UUID regen command.

1 Like