Project

General

Profile

Actions

Defect #39534

closed

Error (undefined method) in issue list PDF export

Added by Thomas Löber 6 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Category:
PDF export
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Hi,

I got an undefined method `custom_field' for nil:NilClass error at https://www.redmine.org/projects/redmine/repository/svn/entry/tags/5.0.6/lib/redmine/export/pdf/issues_pdf_helper.rb#L342.

The error occurs when you try to PDF export a custom field block column that is not part of the tracker of the exported ticket(s). In that case issue.visible_custom_field_values does not contain a custom value for the column, cv is nil and cv.custom_field fails.

cv =
  issue.visible_custom_field_values.detect do |v|
    v.custom_field_id == column.custom_field.id
  end
is_html = cv.custom_field.full_text_formatting?

Best regards,
Thomas

Actions #1

Updated by Thomas Löber 6 months ago

Here is a possible fix:

cv =
  issue.visible_custom_field_values.detect do |v|
    v.custom_field_id == column.custom_field.id
  end
next if cv.nil?
is_html = cv.custom_field.full_text_formatting?

Actions #2

Updated by Marius BĂLTEANU 6 months ago

  • Status changed from New to Confirmed
  • Assignee set to Marius BĂLTEANU
  • Target version set to 5.0.7
Actions #3

Updated by Marius BĂLTEANU 6 months ago

  • Status changed from Confirmed to Resolved
  • Resolution set to Fixed

Fixed with a test, thanks for reporting the issue. The fix will be available in next maintenance releases.

Actions #4

Updated by Marius BĂLTEANU 6 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF