500 error via media library

Created on 21 July 2025, 8 days ago

Problem/Motivation

When using a Chart field in a custom media type (e.g. Chart media) and accessing that media type via a Media reference field from a node using the "Add or select media" media library dialog, Chart module renders a "basic_form" via src/Element/BaseSettings.php processSettings().
However, the media-library fails in several ways:
1. Undefined array key "library" in Drupal\charts\Element\BaseSettings::processSettings() (line 150 of /app/web/modules/contrib/charts/src/Element/BaseSettings.php)
2. Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. Valid plugin IDs for Drupal\charts\ChartManager are: highcharts in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /app/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

Steps to reproduce

  1. Enable Highcharts only
  2. Create Media type using Chart field
  3. Create content type referencing Chart media type
  4. Add node, while adding node, add media
  5. In 'Add or select media' dialog, select Chart media tab
  6. Notice 500 error for Drupal ajax

Watchdog error associated with 500 error is "Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. Valid plugin IDs for Drupal\charts\ChartManager are: highcharts in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /app/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php)."

Proposed resolution

If code in processSettings() specifically ensures $element['#value'] = ['library' => 'highcharts']; before addLibraryElementOptions() is invoked, the plugin error no longer occurs.

Remaining tasks

It's not clear to me how best to include this logic in processSettings() given the other form scenarios already in that function.

User interface changes

No.

API changes

No.

Data model changes

No.

πŸ› Bug report
Status

Active

Version

5.1

Component

Code

Created by

πŸ‡³πŸ‡ΏNew Zealand jonathan_hunt

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jonathan_hunt
  • πŸ‡ΊπŸ‡ΈUnited States andileco

    Thank you for this report, @jonathan_hunt. I like this approach. I'm working on this!

  • πŸ‡ΊπŸ‡ΈUnited States andileco

    Quick question...did you try dev? Also, what base field did you use for your media type?

  • πŸ‡³πŸ‡ΏNew Zealand jonathan_hunt

    Thanks for the response. I just tried 5.1.x-dev, commit ff1b1f7 and the issue remains present. Re base field, the Chart media type has field_media_chart, Field type=Chart.

  • πŸ‡ΊπŸ‡ΈUnited States andileco

    Did you save Highcharts in the Charts Default Settings form (under Config > Content Authoring)? Or any other details you can provide? I am having trouble recreating the issue. Thank you!

  • πŸ‡³πŸ‡ΏNew Zealand jonathan_hunt

    Yes, Hightcharts, Line, etc. is configured under /admin/config/content/charts

    _core:
      default_config_hash: 9yjlE9uRZ55NCXhNhQk_v9NJm2Zgyb4BvLVhLRUXrcI
    charts_default_settings:
      library: highcharts
      type: line
      display:
        title: ''
        title_position: out
        subtitle: ''
        data_labels: false
        data_markers: false
        connect_nulls: false
        legend_position: right
        background: ''
        three_dimensional: 0
        colors:
          - '#006fb0'
          - '#f07c33'
          - '#342e9c'
          - '#579b17'
          - '#3f067a'
          - '#cbde67'
          - '#7643b6'
          - '#738d00'
          - '#c157c7'
          - '#02dab1'
          - '#ed56b4'
          - '#d8d981'
          - '#004695'
          - '#736000'
          - '#a5a5ff'
          - '#833a00'
          - '#ff9ee9'
          - '#684507'
          - '#fe4f85'
          - '#5d0011'
          - '#ffa67b'
          - '#88005c'
          - '#ff9b8f'
          - '#85000f'
          - '#ff7581'
        polar: 0
        tooltips: true
        dimensions:
          width: ''
          width_units: '%'
          height: ''
          height_units: ''
        gauge:
          max: '100'
          min: '0'
          green_from: '85'
          green_to: '100'
          yellow_from: '50'
          yellow_to: '85'
          red_from: '0'
          red_to: '50'
        color_changer: false
      xaxis:
        title: ''
        labels_rotation: '0'
      yaxis:
        title: ''
        min: ''
        max: ''
        prefix: ''
        suffix: ''
        decimal_count: ''
        labels_rotation: '0'
      library_config:
        legend:
          layout: horizontal
          background_color: ''
          border_width: '0'
          item_style:
            color: ''
            overflow: ''
          shadow: false
        3d_library: true
        accessibility_library: true
        annotations_library: false
        boost_library: false
        data_library: false
        exporting_library: true
        texture_library: false
        global_options:
          lang:
            download_CSV: 'Download CSV'
            download_JPEG: 'Download JPEG image'
            download_PDF: 'Download PDF document'
            download_PNG: 'Download PNG image '
            download_SVG: 'Download SVG vector image'
            download_XLS: 'Download XLS'
            exit_fullscreen: 'Exit from full screen'
            hide_data: 'Hide data table'
            loading: Loading...
            main_breadcrumb: Main
            thousands_sep: ' '
            decimal_point: .
            no_data: 'No data to display'
            print_chart: 'Print chart'
            reset_zoom: 'Reset zoom'
            reset_zoom_title: 'Reset zoom level 1:1'
            view_data: 'View data table'
            view_fullscreen: 'View in full screen'
            context_button_title: 'Chart context menu'
            drill_up_text: 'Back to {series.name}'
            invalid_date: 'Invalid date'
            months:
              - January
              - February
              - March
              - April
              - May
              - June
              - July
              - August
              - September
              - October
              - November
              - December
            short_months:
              - Jan
              - Feb
              - Mar
              - Apr
              - May
              - Jun
              - Jul
              - Aug
              - Sept
              - Oct
              - Nov
              - Dec
            weekdays:
              - Sunday
              - Monday
              - Tuesday
              - Wednesday
              - Thursday
              - Friday
              - Saturday
            short_weekdays:
              - Sun
              - Mon
              - Tue
              - Wed
              - Thurs
              - Frid
              - Sat
            export_data:
              annotation_header: Annotations
              category_datetime_header: DateTime
              category_header: Category
            numeric_symbols:
              - k
              - M
              - G
              - T
              - P
              - E
    advanced:
      debug: true
      requirements:
        cdn: true
    dependencies:
      module:
        - charts_highcharts
Production build 0.71.5 2024