Getting timeouts during JSM Assets import

Hello folks, I am working on a Forge app that does asset imports into the JSM Assets platform. The app fetches CMDB data from a 3rd party product API and syncs it with Assets in JSM.

I am using Imports REST API for schema creation and asset sync process. I am using the Atlassian forge framework for the same. For schema creation, we create 1 object type having 20 attributes in a single API call. We are using /mapping endpoint for the same. 6 of the attributes are of type referenced_object.
I am not doing any concurrent calls to this endpoint and the app waits for the API response every time.

The issue is in Forge each function should complete its execution in 25 sec. but the schema creation endpoint sometimes starts getting timed out after some successful schema creation API calls.

Our functions have a time limit of 25 seconds, so If an API call’s response takes more than 24 seconds, then we terminate the function and do a retry. Such retries are done 4 times.

In this case, we are not waiting for a response, so it can be the case that the next API call is done before receiving the response from another. But this is something that is out of our control as we get a limit of 25 seconds for function invocation from Forge.

I also kept the retry time to 5 minutes and the same timeout issue was observed.

Also after these retries, we tried to start the import. Here also we got timeout for the first time and on retry we got this error {"errorCode":"IN_PROGRESS","result":"error"}.

Can someone recommend any best practices for passing attributes in /mapping endpoint or how can we avoid timeouts?
Also, how much should be the wait time between starting the import and after the submitting schema and mapping configuration?

1 Like

@SagarGujarati,

I’m not sure this is an answer, but there is a new Forge tutorial specific to JSM Assets:

https://developer.atlassian.com/platform/forge/assets-import-app/

Do you still hit the invocation limits following those instructions?

Hi @ibuchanan Thanks for the update related to the new tutorial for JSM Asset imports.

I tried following the steps provided in the tutorial. Though the new UI component seems to work fine, I faced the below issue while calling the Imports REST API using the asUser method.

The API works fine for the /executions endpoint but gives 401 error when I try to call /mapping endpoint with PATCH method. Below is the code snippet:

const asUserRequest = await api
    .asUser()
    .requestJira(
      route`/jsm/assets/workspace/${context.workspaceId}/v1/importsource/${context.importId}/mapping`,
      {
        method: "PATCH",
        body: JSON.stringify(commonSchemaPayload),
      }
    );

And the response I am getting:

{ "code": 401, "message": "Unauthorized; scope does not match" }

Permissions in the app manifest:

permissions:
  content:
    styles:
      - unsafe-inline
  scopes:
    - storage:app
    - import:import-configuration:cmdb

Can you check with the dev/support team if I am missing something here?
Let me know if more information is required.

1 Like