Fix TypeError when JSON table contains array instead of hash

What does this MR do and why?

Problem

Sentry error: https://new-sentry.gitlab.net/organizations/gitlab/issues/1815052

TypeError: no implicit conversion of String into Integer (TypeError)

        return unless json['markdown']
                           ^^^^^^^^^^
  from lib/banzai/filter/json_table_filter.rb:47:in `process_json_table'
  from lib/banzai/filter/json_table_filter.rb:26:in `block in call'

Solution

Check that parsed JSON is a Hash before accessing string keys to prevent TypeError when JSON contains an array.

How to set up and validate locally

  1. Open any issue or merge request
  2. Leave a comment with this content

Screenshot_2025-08-12_at_14.06.05

  1. It should be rendered as an empty table instead of an error
Before After
Screenshot_2025-08-12_at_14.05.06 Screenshot_2025-08-12_at_14.04.19

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Vasilii Iakliushin

Merge request reports

Loading