instagram_lite_media value sometimes includes invalid characters, preventing config import

Created on 4 March 2024, 9 months ago
Updated 4 April 2024, 8 months ago

I have noticed a couple times over the past few weeks that when importing config, the import fails due to the following message:

Invalid data type in config block.block.instagramliteblock, found in file ../config/block.block.instagramliteblock.yml: yaml_parse(): reading error encountered during parsing: control characters are not allowed (line 1, column 1)

I've included the full contents of that file below, but have noticed that if I remove instagram_lite_media, the config will import successfully, then the module regenerates that value anyway. Generally speaking, I've wondered if that info should be stored in config at all, since it continually updates as the Instagram account gets new posts (and, based on the example below, it includes environment-specific absolute URLs), but at a minimum, being able to avoid that import error would be nice.

Thanks for taking a look!

uuid: cd00340e-d1b8-4035-b6b5-6e86c2620760
langcode: en
status: true
dependencies:
  module:
    - instagram_lite
  theme:
    - mshsl
id: instagramliteblock
theme: mshsl
region: hidden
weight: 0
provider: null
plugin: instagram_lite
settings:
  id: instagram_lite
  label: Trending
  label_display: visible
  provider: instagram_lite
  instagram_lite_token: IGQWRQdU9SamNJSGFVTXRxa1pTbnV1VUt3cEY2RTNGdmlkWVFjTlZApR0VVcWgtRFZAoTDUyZA1BKY0ozeE9abnM4SmZA5cVJpNTRMRmhjeWRCSmZAfZAUFVTXhpUU5HTmhwVGZAmV2JyMENEbk1XUQZDZD
  instagram_lite_limit: '9'
  instagram_lite_autoplay: false
  instagram_lite_video: false
  instagram_lite_post_caption: false
  instagram_lite_expires_in: '1696337814'
  instagram_lite_account_owner: true
  instagram_lite_hide_block: true
  instagram_lite_media: |-
    a:9:{i:0;a:7:{s:2:"id";s:17:"17867874228036002";s:10:"media_type";s:14:"CAROUSEL_ALBUM";s:9:"media_url";s:130:"https://mshsl.ddev.site/sites/default/files/instagram_lite/instagramliteblock/431594583_1068581361111842_6500583981259058816_n.jpg";s:9:"timestamp";s:24:"2024-03-04T14:25:54+0000";s:9:"permalink";s:40:"https://www.instagram.com/p/C4GHqGauViZ/";s:7:"caption";s:150:"Congratulations to our Boys Swim and Dive Winners! 
     
    Class A: Breck/Blake 
    Class AA: Edina 
     
    For full results, go to http://mshsl.org/boysswimandive";s:10:"attributes";O:30:"Drupal\Core\Template\Attribute":1:{s:10:"*storage";a:1:{s:5:"class";O:35:"Drupal\Core\Template\AttributeArray":2:{s:8:"*value";a:1:{i:0;s:11:"insta-image";}s:7:"*name";s:5:"class";}}}}i:1;a:7:{s:2:"id";s:17:"18069575614491001";s:10:"media_type";s:5:"IMAGE";s:9:"media_url";s:129:"https://mshsl.ddev.site/sites/default/files/instagram_lite/instagramliteblock/431648129_258965770503294_7524740257543453664_n.jpg";s:9:"timestamp";s:24:"2024-03-04T14:25:10+0000";s:9:"permalink";s:40:"https://www.instagram.com/p/C4GHktjO8lg/";s:7:"caption";s:713:"At the beginning of his varsity boys high school soccer coaching career in 1981, Stillwater's Phil Johnson had a style that mirrored that of many young coaches. The focus was on the short-term, and frankly, that meant winning. He believed, like many other young coaches, that he could control winning the game.

    After his coaching epiphany, Johnson and the Ponies bolted to a 440-118-62 record to complete a coaching journey of 451-156-64 that now includes induction into the Minnesota State High School League's Hall of Fame. Johnson is one of two coaches in the Class of 2024 that will be inducted on Sunday, April 14 at the InterContinental St. Paul Riverfront Hotel. Tickets are now on sale at mshsl.org/hof24";s:10:"attributes";O:30:"Drupal\Core\Template\Attribute":1:{s:10:"*storage";a:1:{s:5:"class";O:35:"Drupal\Core\Template\AttributeArray":2:{s:8:"*value";a:1:{i:0;s:11:"insta-image";}s:7:"*name";s:5:"class";}}}}i:2;a:6:{s:2:"id";s:17:"18055925275499208";s:10:"media_type";s:5:"IMAGE";s:9:"media_url";s:128:"https://mshsl.ddev.site/sites/default/files/instagram_lite/instagramliteblock/430610303_717108407079943_889536700956192010_n.jpg";s:9:"timestamp";s:24:"2024-03-01T15:25:13+0000";s:9:"permalink";s:40:"https://www.instagram.com/p/C3-gD4ZuCSG/";s:10:"attributes";O:30:"Drupal\Core\Template\Attribute":1:{s:10:"*storage";a:1:{s:5:"class";O:35:"Drupal\Core\Template\AttributeArray":2:{s:8:"*value";a:1:{i:0;s:11:"insta-image";}s:7:"*name";s:5:"class";}}}}i:3;a:6:{s:2:"id";s:17:"18027555256785237";s:10:"media_type";s:5:"IMAGE";s:9:"media_url";s:129:"https://mshsl.ddev.site/sites/default/files/instagram_lite/instagramliteblock/430443957_922563725979655_8041773152782925888_n.jpg";s:9:"timestamp";s:24:"2024-03-01T15:24:56+0000";s:9:"permalink";s:40:"https://www.instagram.com/p/C3-gB1dOAG5/";s:10:"attributes";O:30:"Drupal\Core\Template\Attribute":1:{s:10:"*storage";a:1:{s:5:"class";O:35:"Drupal\Core\Template\AttributeArray":2:{s:8:"*value";a:1:{i:0;s:11:"insta-image";}s:7:"*name";s:5:"class";}}}}i:4;a:6:{s:2:"id";s:17:"17907302738928313";s:10:"media_type";s:5:"IMAGE";s:9:"media_url";s:128:"https://mshsl.ddev.site/sites/default/files/instagram_lite/instagramliteblock/430091205_797478055755197_425435587239233120_n.jpg";s:9:"timestamp";s:24:"2024-02-29T15:11:33+0000";s:9:"permalink";s:40:"https://www.instagram.com/p/C375s-8s6kH/";s:10:"attributes";O:30:"Drupal\Core\Template\Attribute":1:{s:10:"*storage";a:1:{s:5:"class";O:35:"Drupal\Core\Template\AttributeArray":2:{s:8:"*value";a:1:{i:0;s:11:"insta-image";}s:7:"*name";s:5:"class";}}}}i:5;a:6:{s:2:"id";s:17:"18001603760218713";s:10:"media_type";s:14:"CAROUSEL_ALBUM";s:9:"media_url";s:129:"https://mshsl.ddev.site/sites/default/files/instagram_lite/instagramliteblock/430155515_310995938650246_7111820252776716846_n.jpg";s:9:"timestamp";s:24:"2024-02-29T14:59:24+0000";s:9:"permalink";s:40:"https://www.instagram.com/p/C374T_VuTuN/";s:10:"attributes";O:30:"Drupal\Core\Template\Attribute":1:{s:10:"*storage";a:1:{s:5:"class";O:35:"Drupal\Core\Template\AttributeArray":2:{s:8:"*value";a:1:{i:0;s:11:"insta-image";}s:7:"*name";s:5:"class";}}}}i:6;a:6:{s:2:"id";s:17:"18336185686098757";s:10:"media_type";s:5:"IMAGE";s:9:"media_url";s:129:"https://mshsl.ddev.site/sites/default/files/instagram_lite/instagramliteblock/430914897_808300077801639_1352877009464966705_n.jpg";s:9:"timestamp";s:24:"2024-02-29T14:58:23+0000";s:9:"permalink";s:40:"https://www.instagram.com/p/C374Mj8O_ef/";s:10:"attributes";O:30:"Drupal\Core\Template\Attribute":1:{s:10:"*storage";a:1:{s:5:"class";O:35:"Drupal\Core\Template\AttributeArray":2:{s:8:"*value";a:1:{i:0;s:11:"insta-image";}s:7:"*name";s:5:"class";}}}}i:7;a:7:{s:2:"id";s:17:"18336040612105242";s:10:"media_type";s:14:"CAROUSEL_ALBUM";s:9:"media_url";s:128:"https://mshsl.ddev.site/sites/default/files/instagram_lite/instagramliteblock/430389080_421188393758313_385855633729207809_n.jpg";s:9:"timestamp";s:24:"2024-02-28T18:53:34+0000";s:9:"permalink";s:40:"https://www.instagram.com/p/C35uULkuIDh/";s:7:"caption";s:180:"Photos from the Girls Hockey State Tournament Semifinal and Championship games are now available to view and purchase! Head on over to www.mshsl.org/girlshockey to buy yours today.";s:10:"attributes";O:30:"Drupal\Core\Template\Attribute":1:{s:10:"*storage";a:1:{s:5:"class";O:35:"Drupal\Core\Template\AttributeArray":2:{s:8:"*value";a:1:{i:0;s:11:"insta-image";}s:7:"*name";s:5:"class";}}}}i:8;a:7:{s:2:"id";s:17:"18016167473490546";s:10:"media_type";s:5:"IMAGE";s:9:"media_url";s:129:"https://mshsl.ddev.site/sites/default/files/instagram_lite/instagramliteblock/430278026_793509029482533_7311179855822995471_n.jpg";s:9:"timestamp";s:24:"2024-02-28T17:35:38+0000";s:9:"permalink";s:40:"https://www.instagram.com/p/C35lZV5OT84/";s:7:"caption";s:158:"Photos from the Gymnastics State Tournament Championships are now available to view and purchase! Head on over to www.mshsl.org/gymnastics to buy yours today.";s:10:"attributes";O:30:"Drupal\Core\Template\Attribute":1:{s:10:"*storage";a:1:{s:5:"class";O:35:"Drupal\Core\Template\AttributeArray":2:{s:8:"*value";a:1:{i:0;s:11:"insta-image";}s:7:"*name";s:5:"class";}}}}}
  instagram_lite_media_path: 'public://instagram_lite/instagramliteblock/'
  instagram_lite_block_id: instagramliteblock
  instagram_lite_use_blazy: null
  instagram_lite_image_style: ''
visibility: {  }
πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kurttrowbridge

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

Merge Requests

Comments & Activities

  • Issue created by @kurttrowbridge
  • Status changed to Needs review 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States kurttrowbridge

    This got in my way more this week, so I tried to figure out how to fix it. :)

    I figured out that when the instagram_lite_media config value gets serialized before it's stored, null characters were being included in the output, and YAML won't parse that cleanly. By doing a preg_replace() that removes those, the config value is cleaned up, and the visual output of the Instagram feed on the page appears to be unaffected.

    In addition to the provided merge request, I've attached a screenshot of the diff in my site's config after this patch has been applied, showing the removal of the null characters and the otherwise unaltered data (I guess it also turns from a multiline string to a single line...which is possibly fine? I don't display captions, but I do see line breaks in multiline captions get removed, which I could see being a problem for someone else).

    This gets outside my typical wheelhouse a bit, so any additional reviews would be much appreciated. Thanks!

Production build 0.71.5 2024