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

customfield generated out of template does not gets interpreted as an array #168

Open
holger-waschke opened this issue Jun 6, 2023 · 1 comment

Comments

@holger-waschke
Copy link
Contributor

holger-waschke commented Jun 6, 2023

I have a customfield 23210. If I pass is statically as an array [{'key':'PSK-713555'},{'key':'PSK-953155'}] it works just fine, if i pass it trough the template the output is exactly the same but it doesnt get passed as an array

  - name: mon_alarm
    project: MON
    add_group_labels: false
    issue_type: Alarm
    fields:
      customfield_23210: '{{ template "jira.psk" . }}'
      #customfield_23210: [{'key':'PSK-713555'},{'key':'PSK-953155'}]

template definition:
{{ define "jira.psk" -}}{{ with index .Alerts 0 -}}{{- $elements := split .Labels.insight_psk "," -}}[{{- range $index, $element := $elements -}}{{ if $index }},{{ end }}{'key':'{{ $element }}'}{{ end -}}]{{ end -}}{{ end -}}

log output:

Jun 05 21:18:14 alert-test01.1.xxx jiralert[19840]: level=debug ts=2023-06-05T19:18:14.04358488Z caller=template.go:75 msg="executing template" template="{{ template \"jira.psk\" . }}"
Jun 05 21:18:14 alert-test01.1.xxx jiralert[19840]: level=debug ts=2023-06-05T19:18:14.043612402Z caller=template.go:96 msg="template output" output=[{'key':'PSK-713555'},{'key':'PSK-953155'}]

Error from Jira:
Jun 05 19:24:16 alert-test01.1.xxx jiralert[7224]: level=error ts=2023-06-05T17:24:16.717689448Z caller=main.go:180 msg="error handling request" statusCode=400 statusText="Bad Request" err="JIRA request https://projektportal.xxx/jira/rest/api/2/issue returned status 400 Bad Request, error \"request failed. Please analyze the request body for more details. Status code: 400\", body \"{\\\"errorMessages\\\":[],\\\"errors\\\":{\\\"customfield_23210\\\":\\\"data was not an array\\\"}}\"" receiver=mon_alarm groupLabels="unsupported value type"

what i noticed is a slightly different process mode, I guess in the function "deepCopyWithTemplate" it doesn´t get interpreted as an array from the reflect library

this is from the log output if it works
Unknowns:map[customfield_23210:[map[key:PSK-713555] map[key:PSK-953155]]]}"
and this is from the template which doesnt work
Unknowns:map[customfield_23210:[{'key':'PSK-713555'},{'key':'PSK-953155'}]]}"

@EngineTech
Copy link

I also need this functionality, but as far as I understand, this is a limitation of the text template that returns a non-alternative string object that is substituted after YML serialization.

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

2 participants