PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 31, 2022

[FIXED] Symfony update fails with YAML errors

 January 31, 2022     php, symfony, yaml     No comments   

Issue

I have a web application currently running on Symfony 4.3.5 without any problems.

I call "php composer.phar update" in my project directory. Composer starts to download and upgrade packages to version 4.4 and finally fails with


Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!  
!!  In FileLoader.php line 180:
!!                                                                                 
!!    The file "/home/markus/Programming/personal/config/packages/sonata_admin.ya  
!!    ml" does not contain valid YAML: Unexpected characters near "                
!!    - {                                                                          
!!        route: app_workflows_erzeugemassnahmen_index,                            
!!        label: "Fällige Massnahmen erstellen",                                   
!!        roles: [ROLE_SUPER_ADMIN, ROLE_ADMIN_WORKFLOWS]                          
!!      }" at line 76 (near "  }") in /home/markus/Programming/personal/config/pa  
!!    ckages/sonata_admin.yaml (which is loaded in resource "/home/markus/Program  
!!    ming/personal/config/packages/sonata_admin.yaml").                           
!!                                                                                 

It complains about the same error in In YamlFileLoader.php line 693: and In Inline.php line 94:

This "sonata_admin.yaml" file worked perfectly before. I use "yamllint" to check the file and it does not find anything wrong. I upload the file to online YAML checks and they don't find any problem.

Interesting observations: - The message says that the error is in line 76 but the surrounding text shown is from line 48 - When I empty the file completely, the upgrade fails with nearly the same error in a completely different file

I use PHP 7.3 and most recent composer. Any ideas?

Here is the config file:

---
# Sonata Admin Bundle
sonata_block:
  default_contexts: [cms]
  blocks:
    # enable the SonataAdminBundle block
    sonata.admin.block.admin_list: ~
    sonata.block.service.geburtstagsliste: ~
    sonata.block.service.vertragsliste: ~
    sonata.block.service.jubilare: ~
    sonata.block.service.konsistenzcheck: ~
    sonata.block.service.workflowstatistik: ~
    sonata.block.service.schulungsliste: ~
    # sonata.block.service.testblock: ~

sonata_admin:
  persist_filters: true
  # for hide mosaic view button on all screen using `false`
  show_mosaic_button: false
  title: "Personal Admin"
  title_logo: "/bundles/sonatauser/default_avatar.png"
  security:
    handler: sonata.admin.security.handler.role
  dashboard:
    groups:
      Stammdaten Workflows:
        icon: '<i class="glyphicon glyphicon-folder-close"></i>'
        roles: [ROLE_ADMIN_STAMMDATEN, ROLE_SUPER_ADMIN]
      Stammdaten:
        icon: '<i class="glyphicon glyphicon-folder-close"></i>'
        roles: [ROLE_ADMIN_STAMMDATEN, ROLE_SUPER_ADMIN]
      Schulungen:
        icon: '<i class="glyphicon glyphicon-folder-close"></i>'
        label: ~
        label_catalogue: ~
        items:
          - {route: app_schulungsplanung_list, label: "Schulungsplanung"}
          - admin.schulungsevent
        roles: [ROLE_ADMIN_SCHULUNGSPLANUNG, ROLE_SUPER_ADMIN]
      Workflows/Massnahmen:
        icon: '<i class="glyphicon glyphicon-folder-close"></i>'
        items:
          - {
            route: app_workflows_ausstehendemassnahmen_index,
            label: "Übersicht Massnahmen",
          }
          - {
            route: app_workflows_erzeugemassnahmen_index,
            label: "Fällige Massnahmen erstellen",
            roles: [ROLE_SUPER_ADMIN, ROLE_ADMIN_WORKFLOWS],
          }
        roles: [ROLE_USER_WORKFLOWS, ROLE_SUPER_ADMIN, ROLE_ADMIN_WORKFLOWS]
      Workflows/Offboarding:
        icon: '<i class="glyphicon glyphicon-folder-close"></i>'
        items:
          - {
            route: app_workflows_ereignisuebersicht_index,
            label: "Übersicht Offboarding",
          }
          - {
            route: app_bewertungen_bewertungenuebersicht_index,
            label: "Übersicht Bewertungen",
          }
        roles: [ROLE_SUPER_ADMIN, ROLE_ADMIN_WORKFLOWS]
      Workflows/Bewertungen:
        icon: '<i class="glyphicon glyphicon-folder-close"></i>'
        items:
          - {
            route: app_bewertungen_bewertungenuebersicht_index,
            label: "Übersicht Bewertungen",
          }
        roles: [ROLE_USER_ZEUGNISSE]
      Workflows/Onboarding:
        icon: '<i class="glyphicon glyphicon-folder-close"></i>'
        items:
          - {
            route: app_workflows_ereignisuebersicht_onboardinguebersicht,
            label: "Übersicht Onboarding",
          }
          - {
            route: app_onboardingwizard_onboardingwizard_index,
            label: "Onboarding Wizard",
          }
        roles: [ROLE_SUPER_ADMIN, ROLE_ADMIN_WORKFLOWS]
    blocks:
      - {
        position: left,
        type: sonata.block.service.geburtstagsliste,
        roles: [ROLE_PERSONAL, ROLE_SUPER_ADMIN],
      }
      - {
        position: left,
        type: sonata.block.service.workflowstatistik,
        roles: [ROLE_ADMIN_WORKFLOWS, ROLE_SUPER_ADMIN],
      }
      - {
        position: right,
        type: sonata.block.service.vertragsliste,
        roles: [ROLE_PERSONAL, ROLE_SUPER_ADMIN],
      }
      - {
        position: right,
        type: sonata.block.service.schulungsliste,
        roles: [ROLE_PERSONAL, ROLE_SUPER_ADMIN],
      }
      - {
        position: right,
        type: sonata.block.service.konsistenzcheck,
        roles: [ROLE_PERSONAL, ROLE_SUPER_ADMIN],
      }
      - {
        position: left,
        type: sonata.block.service.jubilare,
        roles: [ROLE_PERSONAL, ROLE_SUPER_ADMIN],
      }

Solution

So, I'm just guessing here, that the reason is the { and } in your multi-line mappings. What I don't get is that it ever worked ... (maybe the yaml-parser got stricter?)

Anyway, as far as I can tell the syntax definition appears to NOT require { and } if the mapping is split over multiple lines :

-
  name: Mark McGwire
  hr:   65
  avg:  0.278
-
  name: Sammy Sosa
  hr:   63
  avg:  0.288

source: 2.1 Collections / Example 2.4, Sequence of Mappings

in fact, the only place where { follows a - in the spec is when the mapping is written in one line.

Sooo, maybe it's this.



Answered By - Jakumi
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing