How to debug a cloud plugin?

Hello everyone,

I am trying to build my first JIRA cloud plugin.

I uploaded a new private connector app with a webPanel module on issue pages.

When I open an issue page, I just see an error message:

Error rendering ‘com.atlassian.plugins.atlassian-connect-plugin:app_test__whos-looking’. Please contact your Jira administrators.

How do I go about debugging this? A search pointed me towards an ‘atlassian-jira.log’, but since I am on a cloud instance, I don’t have access to any logs.

I only know from my own server logs that the URL for that view is never called.

What’s my starting point?

Thank you very much!

PS: I used the search and read the docs, I apologize if this is obvious and appreciate hints to any existing doc that will solve my issue.

1 Like

Hi @vp1,

I’m sorry to hear that. You as an app developer should never see this kind of error message. I suspect there is some subtle problem in your app descriptor that we are missing in validation.

Could you please post your app descriptor here?

Cheers,
Einar

1 Like

@epehrson sure, here you go!

If you can point me to some docs to avoid this problem in the future - I’m not looking for help on every bit of my app, but unfortunately couldn’t find a starting point to even debug.

Also, unfortunately, neither my pages are loading correctly. When I inspect the network, the “greetings” page is loaded correctly, but it won’t display within JIRA (“App not responding”). I followed the setup of the JS connector, but somehow that doesn’t help.

EDIT: Also, my testing webhook is never called either.

EDIT2: You as a staff can also directly look at my private app if that helps you more: https://marketplace.atlassian.com/manage/plugins/trustshoring_test/versions

Anyways, first things first, here’s my descriptor:

{
  "name": "Atlassian Connect Add-on",
  "description": "An example add-on description",
  "key": "my_test",
  "baseUrl": "https://jira.MY-DOMAIN.com",
  "vendor": {
    "name": "Test",
    "url": "/"
  },
  "version": "1.0.3",
  "authentication": {
    "type": "jwt"
  },
  "lifecycle": {
    "installed": "/installed",
    "uninstalled": "/uninstalled",
    "enabled": "/enabled",
    "disabled": "/disabled"
  },
  "scopes": [
    "READ",
    "WRITE",
    "admin",
    "act_as_user"
  ],
  "modules": {
    "webPanels": [
      {
        "key": "whos-looking",
        "name": {
          "value": "Whos Looking?"
        },
        "url": "https://jira.MY-DOMAIN.com/views/whos-looking/{issue.key}",
        "location": "atl.jira.view.issue.right.context"
      }
    ],
    "webhooks": [
      {
        "event": "jira:issue_created",
        "url": "https://jira.MY-DOMAIN.com/hooks/issue_created"
      }
    ],
    "generalPages": [
      {
        "url": "/helloworld",
        "key": "hello-world",
        "location": "system.top.navigation.bar",
        "name": {
          "value": "Greeting"
        }
      }
    ]
  }
}

Thanks for your help!

@vp1, so I’m fairly certain the problem is the absolute URLs you are using in your descriptor.

Generally, all URL fields for modules are expected to be relative to the app baseUrl, but I don’t think it’s ever validated and some modules just happen to work anyway. For Web Panels, the documentation for the url field actually says:

The URL of the add-on resource that provides the web panel content. This URL must be relative to the add-on’s baseUrl.

You are hitting a server error on Atlassian’s side, so there is nothing for you to debug. This shouldn’t happen.

As to the Greeting page not loading, it may be because you are not Atlassian Connect JavaScript API. This is described in the UI tools section of the overview.

1 Like

This seems to be a more subtle bug that Einar is trying to solve with you. However, as more general topic, if you want to debug your cloud application you can also host it locally on your PC and use ngrok to have your app in Jira communicate with your local machine.

Check out the Getting Started guide for more information.

@epehrson thank you! I really missed that part.

That did the trick.

I’m still left with my Connect JS problem. I have previously read that documentation, and I just tried following it from scratch.

Below is my greetings page. My console shows no errors. When I copy the iframe URL and open it in a new tab, my developer tools show me that the all-debug.js is loaded correctly from the right domain, and the iframe content is definitely loaded correctly when I inspect it in my dev tools. And yet, it shows the classic “app not responding”.

I am again unsure how to debug this connector issue. Is there documentation on that anywhere? My console gives me no errors.

<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="//aui-cdn.atlassian.com/aui-adg/5.9.12/css/aui.min.css" media="all">
</head>
<body>

<div class="ac-content">
    <p>Hello World</p>
    <div id="your-id-here">
        <p>Addon content goes here</p>
    </div>

    ...this area reserved for our resize sensor divs
</div>


<script id="connect-loader" data-options="sizeToParent:true;">
    (function() {
        var getUrlParam = function (param) {
            var codedParam = (new RegExp(param + '=([^&]*)')).exec(window.location.search)[1];
            return decodeURIComponent(codedParam);
        };

        var baseUrl = getUrlParam('xdm_e') + getUrlParam('cp');
        var options = document.getElementById('connect-loader').getAttribute('data-options');

        var script = document.createElement("script");
        script.src = baseUrl + '/atlassian-connect/all-debug.js';

        if(options) {
            script.setAttribute('data-options', options);
        }

        document.getElementsByTagName("head")[0].appendChild(script);
    })();
</script>

</body>
</html>

Thanks @yvesriel ! I might start using ngrok, but unfortunately that only speeds up my testing cycle (no git-push-deploy), but won’t help me actually debug my problems - or am I missing something?

Your iframe content looks good to me, @vp1. Not sure what the problem is.

In our case, it allows us to debug the server code as well. Since the code is running on your own server, you can run your server in debug mode. For example, we can put breakpoints and figure out why the add-on doesn’t allow a connection, etc.

@epehrson any idea how to debug this? any patterns that should be visible in the console, but aren’t?

@yvesriel that’s true - but I don’t see how this could possibly be a server-side problem. if you could in short explain your theory, that would greatly help me find a solution for this.

Not sure, @vp1. I just tried using your provided iframe HTML with this app descriptor and it loaded just fine.