Error in print format on line 19: the JSON object must be str, bytes or bytearray, not NoneType

After creating an invoice and manually updating the E-Invoice details, I am getting the following error, while trying to print the invoice with the default GST Tax Invoice format:

Error in print format on line 19: the JSON object must be str, bytes or bytearray, not NoneType

This fomat is the default, non-customizable format so this can’t be an error while setting up ERPNext. What could be the problem and how do we solve it?

Update:

Original Code:

{% if doc.irn %}
{% set e_invoice_log = frappe.db.get_value( "e-Invoice Log", doc.irn,
("invoice_data", "signed_qr_code"), as_dict=True ) %}

{% if e_invoice_log %}
{% set invoice_data = json.loads(e_invoice_log.invoice_data) %}
{% set date_format = frappe.db.get_single_value("System Settings",'date_format').replace("mm","MM")
%}

<div style="padding-top:5px !important">
	<!-- invoice qr  -->
	<div style="padding-bottom:5px !important">
		{{ web_block('e-Invoice QR', values={'e_invoice_qr_text':
		e_invoice_log.signed_qr_code }) }}
	</div>

	<!-- IRN -->
	<p class="field-property">
		<b>IRN : </b>{{ doc.irn }}
	</p>
	<!-- Ack no -->
	<p class="field-property">
		<b>Ack No.</b> {{ invoice_data.get("AckNo") if doc.irn and invoice_data.get("AckNo")
		else '' }}
	</p>
	<!-- Ack Date -->
	<p class="field-property">
		<b>Ack Dt.</b>
		{{ frappe.utils.format_datetime(invoice_data.get("AckDt"),date_format) if doc.irn and
		invoice_data.get("AckDt") else '' }}
	</p>
</div>
{% endif %}
{% endif %}

Modified Code:

{% if doc.irn %}
  {% set e_invoice_log = frappe.db.get_value("e-Invoice Log", doc.irn,
    ("invoice_data", "signed_qr_code"), as_dict=True) %}

  {% if e_invoice_log and e_invoice_log.invoice_data %}
    {% set invoice_data = json.loads(e_invoice_log.invoice_data) %}
    {% set date_format = frappe.db.get_single_value("System Settings", "date_format").replace("mm", "MM") %}

    <div style="padding-top:5px !important">
      <div style="padding-bottom:5px !important">
        {{ web_block('e-Invoice QR', values={'e_invoice_qr_text': e_invoice_log.signed_qr_code}) }}
      </div>

      <p class="field-property"><b>IRN : </b>{{ doc.irn }}</p>

      <p class="field-property">
        <b>Ack No.</b> {{ invoice_data.get("AckNo") or '' }}
      </p>

      <p class="field-property">
        <b>Ack Dt.</b> {{ frappe.utils.format_datetime(invoice_data.get("AckDt"), date_format) if invoice_data.get("AckDt") else '' }}
      </p>
    </div>
  {% endif %}
{% endif %}

This did stop the error from coming but is this the correct solution?