Skip to content

Commit

Permalink
templates: Handle missing values in issues and incidents
Browse files Browse the repository at this point in the history
Handle some missing values in issue and incident templates properly.

The 'default' filter unfortunately handles 'undefined' only, so use a
combination of the filter and the tests to handle both interim and final
None values when accessing fields deep in a structure.
  • Loading branch information
spbnick committed Dec 17, 2023
1 parent ffa8e2a commit 1ea0098
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions kcidb/templates/incident.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
{% macro summary(incident) %}
{%- if incident.test -%}
{{- "Incident in " +
(incident.test.path | default("an unknown test")) +
("an unknown test"
if incident.test.path | default(none) is none
else incident.test.path) +
" on " +
(incident.test.build.architecture |
default("an unknown architecture")) -}}
("an unknown architecture"
if incident.test.build.architecture | default(none) is none
else incident.test.build.architecture) -}}
{%- if incident.issue.report_subject -%}
{{- ": " + incident.issue.report_subject -}}
{%- endif -%}
Expand Down
4 changes: 3 additions & 1 deletion kcidb/templates/issue.j2
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
In {{ branches | length -}}
{{- " branch" if (branches | length) == 1 else " branches" }}:
{% for branch in branches[:max_list_len] %}
{{- " " + branch[0] + " " + branch[1] }}
{{- " " +
("?" if branch[0] is none else branch[0]) + " " +
("?" if branch[1] is none else branch[1]) }}
{% endfor %}
{% if (branches | length) > max_list_len %}
{{- " ..." }}
Expand Down

0 comments on commit 1ea0098

Please sign in to comment.