Forge storage API not working in lifecycle triggers

I am trying to use the lifecycle trigger for deleting previously stored data in Forge Storage at the app install. Below is the manifest code snippet.

    - key: lifecycle-trigger
      function: install-handler
        - avi:forge:installed:app
  - key: main
    path: frontend/configuration/build
      - unsafe-inline
    - storage:app
    - read:jira-user
    - read:servicedesk-request

Trigger handler code snippet.

import { storage } from "@forge/api";

const resetConfig = async () =>
    storage.set("schema-created", false),
    storage.set("scheduler-in-progress", false),

export const installResolver = async () => {
  try {
    await resetConfig();
    console.log("App installed successfully with version 1.0.0.");
  } catch (err) {
    console.error(`Error in app install: ${err.message}`);

I am continuously getting Authentication error at the app install.
Further debugging steps would be helpful.


Surprisingly, until yesterday I was getting the same issue and today’s authentication error went away. But now it looks like avi:forge:installed:app event is not being called and only avi:forge:upgraded:app event is being called.

Workaround that worked for me:

First deploy and install your app,

Second, make some scope changes (maybe temporary) in your manifest file like in your case just remove “- read:jira-user” and again deploy and install the app. Now from the UI, just click on the update button from the Manage Apps. Your life cycle handler should get triggered and the storage api will work perfectly.

@mehul8045 Thanks for the reply,
I tried to remove - read:jira-user and update app from the UI and it worked for me. But is there any other solution using which we can avoid such issues? What if this happens in production as well?

Hey, I have recently opened a support ticket reporting the storage wasn’t working in the install event. Luckily, they fixed it. You should upgrade the storage library to @forge/api: 2.18.1

Hope it can help

1 Like