Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while creating issue in Atlassian JIRA. The step is: Calculating fields #36

Open
mrshorten opened this issue Feb 1, 2023 · 12 comments

Comments

@mrshorten
Copy link

System.NullReferenceException: Object reference not set to an instance of an object. at Seq.App.Jira.JiraIssueReactor.CreateIssue(Event1 evt)
at Seq.App.Jira.JiraIssueReactor.OnAsync(Event1 evt)

Not sure what i am doing wrong. I have all required fields filled out.

@nblumhardt
Copy link

Hi! Are you running v0.2.14 of the app? It looks like some null reference exception bug(s) have been fixed in recent releases.

Knowing the Seq version too might help, if that's not the cause.

HTH!

@mrshorten
Copy link
Author

Yes sorry i am running version 0.2.14 of the app and version 2022.1.7378 of the Seq App. Thanks for the help.

@nblumhardt
Copy link

Hi! I just gave the function in question a quick scan; do you happen to have the "Project Key Property" setting configured? The code suggests that this is optional, but appears to use it in a (non-nullable) dictionary key lookup.

Happy to help fix this however I can; I'm not currently using Jira so it's a little tricky to locate the problem. If we can't track it down by inspection like this, I'll have a shot at making the solution locally-runnable with seqcli app run so that someone with Jira access can spin it up in a debugger.

@mrshorten
Copy link
Author

mrshorten commented Mar 26, 2023

Hello,

Apologies on the delay, yes i do have "Project Key Property" configured. I am however still getting the error. Just to confirm, does this App support Jira cloud? Or just Jira Server?

@jeleleven
Copy link

Hello,

Apologies on the delay, yes i do have "Project Key Property" configured. I am however still getting the error. Just to confirm, does this App support Jira cloud? Or just Jira Server?

I am also having this same issue. My project key is also set.

I do not have any other values that are marked as optional set to a value.

@mrshorten
Copy link
Author

Any thoughts on this? Was really hoping to implement this plugin

@nblumhardt
Copy link

I'll take a fresh look, thanks for the nudge 👍

@nblumhardt
Copy link

Hi again @mrshorten 👋

Supporting Jira is important for us; unfortunately, I've dug into the project and at the moment, the plug-in needs quite a bit of maintenance/upgrading to get onto the modern .NET tooling (no criticism of @aliozgur's efforts intended - it's nice to have this project out there!).

I'm up for spending some time migrating to the new-style CSPROJ projects, .NET 6.0 or 7.0 targets, etc., but it's not something I can turn around very quickly.

I've had a look at the Jira REST API documentation and tinkered for a couple of hours, I think there's a workable alternative in Seq.App.HttpRequest, which is intended for exactly this kind of integration, but I've only made it as far as getting Unauthorized from the API:

image

In case you have better luck than I've had, here's the kind of configuration I'm using.

image

The authentication header is:

Authorization: Basic <encoded>

where the <encoded> part is:

Convert.ToBase64String(Encoding.UTF8.GetBytes("[email protected]:<api_token>"))

The body is a template (see checkbox below body text area):

{ {
  'fields': {
    'description': {
      'content': [
        {
          'content': [
            {
              'text': 'Some amazing comment',
              'type': 'text'
            }
          ],
          'type': 'paragraph'
        }
      ],
      'type': 'doc',
      'version': 1
    },
    'project': {
      'id': '10000'
    },
    'issuetype': {
      'id': '10000'
    },
    'summary': @m
  }
} }

Based on: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post

You could untick the "body is a template" option and just use JSON in there, but Seq.App.HttpRequest has a pretty flexible JSON templating system that's worth trying out.

Sorry this isn't a more complete/useful response. Looping back around here and spending some time helping to get the project updated is on my list :-)

Hope this helps,
Nick

@sipsorcery
Copy link

@nblumhardt thanks for the starting point. I was able to create an issue on Jira but only with hard coded values. As sson as I try and use the template the App crashes and a syntax error is reported. I've tried a few different approaches as well as ChatGPT but no joy.

Is the syntax meant to be this template language?

ChatGPT keeps inisiting it should be something like the below.

Both approaches are crashing the app for me.

{
  "fields": {
    "project": {
      "key": "ITOPS"
    },
    "summary": "{{@m}}",
    "description": {
      "type": "doc",
      "version": 1,
      "content": [
        {
          "type": "paragraph",
          "content": [
            {
              "text": "Triggered at: {{@t}}. Description: X",
              "type": "text"
            }
          ]
        }
      ]
    },
    "issuetype": {
      "name": "Task"
    }
  }
}

@nblumhardt
Copy link

Hi @sipsorcery - yes, that's the template language 👍

ChatGPT's suggestion might work with the "Body is template" field _un-_checked - that version is JSON, and won't be a valid template, hence the crash (I think).

If you get that far, the {{@m}} and {{@t}} bits won't be substituted, but we'll at least know that the JSON schema is correct, and I can then translate it into a valid template for you.

Let me know if this helps!

Best regards,
Nick

@sipsorcery
Copy link

I got the app to stop crashing with "Body is a template" checked using the Body below:

{ {
  'fields': {
    'description': {
      'content': [
        {
          'content': [
            {
              'text': 'Triggered at: {{@t}}. Description: {{@m}}',
              'type': 'text'
            }
          ],
          'type': 'paragraph'
        }
      ],
      'type': 'doc',
      'version': 1
    },
    'project': {
      'key': 'ITOPS'
    },
    'issuetype': {
      'name': 'Task'
    },
    'summary': @m
  }
} }

The resulting Jira task description is:

Triggered at: {{@t}}. Description: {{@m}}

I think my issue isn't the actual template and is instead the fact that I'm using a grouping query for the Seq alert.

image

I've having diffculty working out how to get any useful info into my templates, which rare Mialgun and Jira, for this type of query. However, that's not related to this issue so I probably should ask elsewhere?

@nblumhardt
Copy link

Awesome! The {{...}} bits are not valid, you need something more like:

{ {
  'fields': {
    'description': {
      'content': [
        {
          'content': [
            {
              'text': concat('Triggered at: ', @t, '. Description: ', @m),
              'type': 'text'
            }
          ],
          'type': 'paragraph'
        }
      ],
      'type': 'doc',
      'version': 1
    },
    'project': {
      'key': 'ITOPS'
    },
    'issuetype': {
      'name': 'Task'
    },
    'summary': @m
  }
} }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants