Home > Net >  "A colon cannot be used in an unquoted mapping value" Error in services.yml
"A colon cannot be used in an unquoted mapping value" Error in services.yml

Time:10-22

I've come to ask my question here because I really don't know what to do and I couldn't find the right information on the internet. I am looking to bind parameters for a service used to communicate with the BigQuery API (GCP). To do this I passed the parameters in the "parameters.yml" and binded the parameters in the "services.yml". When I reload the page an error appears : " The file /home/docker/symfony/src/AdminBundle/DependencyInjection/../Resources/config/services.yml" does not contain valid YAML: A colon cannot be used in an unquoted mapping value at line 84 (near " $bucketName: %google_bucket_name%").

Do you have any idea what is causing the problem?

Please find attached the relevant parts of the "services.yml" and "parameters.yml" files

-services.yml

  AdminBundle\Services\CustomerChangeSetService:
    public: true
    autowire: true
    autoconfigure: true
    bind:
      $googleProjectId: "%google_project_id%"
      $googlePath: "%kernel.root_dir%/../%google_token_path%"
      $googleQuery: "%google_bigquery_dataset%"
      $googleConfig: "%config_bigQuery_prod%"
      $tableName: "%google_bigquery_table_customerchangeset%"
      $bucketName: "%google_bucket_name%"

  AdminBundle\Services\APILogsService:
    public: true
    autowire: true
    autoconfigure: true
    bind:
      $googleProjectId: "%google_project_id%"
      $googlePath: "%kernel.root_dir%/../%google_token_path%"
      $googleQuery: "%google_bigquery_dataset%"
      $googleConfig: "%config_bigQuery_prod%"
      $tableName: "%google_bigquery_table_apilogs%"
      $bucketName: "%google_bucket_name%"

  AdminBundle\Services\ImportLicenceCodeService:
    public: true
      autowire: true
      autoconfigure: true
      bind:
        $googleProjectId: "%google_project_id%"
        $googlePath: "%kernel.root_dir%/../%google_token_path%"
        $googleQuery: "%google_bigquery_dataset%"
        $googleConfig: "%config_bigQuery_prod%"
        $tableName: "%google_bigquery_table_importlicencecode%"
        $bucketName: "%google_bucket_name%"

-parameters.yml

    google_token_path: ./google_token.json
    google_project_id: "tests-6tm"
    google_bigquery_dataset: "aco"
    google_bigquery_table_accessmember: "access_member"
    google_bigquery_table_customerchangeset: "customer_change_set"
    google_bigquery_table_apilogs: "api_logs"
    google_bigquery_table_importlicencecode: "import_licence_code"
    google_bucket_name: "lemans-prod"

PS: the code seems to have a problem on the parameters of ImportLicenceCodeService

Thanks in advance for your help ;)

CodePudding user response:

the answer is intention as @bossman already pointed out.

I just wanted to add you could take out a lot of unneeded duplication. when you write it like this:

services:
    _defaults:
        autowire: true
        autoconfigure: true
        bind:
            $googleProjectId: "%google_project_id%"
            $googlePath: "%kernel.root_dir%/../%google_token_path%"
            $googleQuery: "%google_bigquery_dataset%"
            $googleConfig: "%config_bigQuery_prod%"            
            $bucketName: "%google_bucket_name%"

  AdminBundle\Services\CustomerChangeSetService:
    public: true
    bind:
        $tableName: "%google_bigquery_table_customerchangeset%"


  AdminBundle\Services\APILogsService:
    public: true
    bind:
        $tableName: "%google_bigquery_table_apilogs%"


  AdminBundle\Services\ImportLicenceCodeService:
    public: true
    bind:
        $tableName: "%google_bigquery_table_importlicencecode%"
  • Related