Forge storage query : Variable "$range" got invalid value null

Hi,

I’m trying to use the Forge storage system, but I’m having a hard time, even looking deep into the documentation.
I’m trying to follow https://developer.atlassian.com/platform/forge/custom-entities-store-structured-data/

And it’s a UI kit 2 app

I got up to:

manifest:

  storage:
    entities:
    # Define a custom entity for storing project groups
    - name: 'jiraproject-group'
      attributes:
        groupname:
          type: 'string'
        projectkey:
          type: 'string'
      indexes:
        # Index to query project groups by name
      - name: 'by-groupName'
        range:
        - 'groupname'
      - name: 'by-projectkey'
        range:
        - 'projectkey'

got this to run without error (don’t know if it did anything ):


    const projectGroupData = {
      groupname: groupName,
      projectkey: project.key
    };

    await storage
      .entity(jiraprojectGroupEntityPath)
      .set(`group-${uuidv4()}`, projectGroupData);
      }

But when I call:

    const query = await storage
      .entity(jiraprojectGroupEntityPath)
      .query()
      .index('by-groupname')
      .where(WhereConditions.beginsWith(searchQuery))
      .getMany();

I get:

Error: There was an error invoking the function - Variable "$range" got invalid value null at "range.values[0]"; Expected non-nullable type "AppStoredCustomEntityFieldValue!" not to be null.

Am I missing something with storage definition? Partition? I’m a bit fuzzy now.

Nevermind, the problem between the chair and the keyboard…

typo by-groupName != by-groupname

and may be something else… but now it works!

PICNIC error.

Problem In Chair Not In Computer

:upside_down_face:

Still in case someone encounter the same, here was the issue (I just reproced it):

resolver.define('searchGroupsByName', async (payload)

should be

resolver.define('searchGroupsByName', async ({payload, context})

Otherwise you end up with payload = {payload : {myVar:‘ploup’}, context : {…}}
Instead of payload = {myVar:‘ploup’}

Which end up passing on weird variable to the following functions :smiley: