How I Fixed: Invalid configuration for path base_url: can be: string

Hands up if seemingly half the time you spend at the computer, you’re fighting weird errors, instead of writing code.

Yeah, me too.

Whilst updating the front end of CodeReviewVideos, a Symfony 4 website, I encountered the following issue:

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!  
!!  In BaseNode.php line 427:
!!                                                                                 
!!    Invalid configuration for path "eight_points_guzzle.clients.crv_api.base_ur  
!!    l": base_url can be: string                                                  
!!                                                                                 
!!  
!!  In ExprBuilder.php line 189:
!!                             
!!    base_url can be: string  
!!                             
!!  
!!  
Script @auto-scripts was called via post-update-cmd

Strangely, the base_url parameter is a string, afaik:

eight_points_guzzle:
    clients:
        crv_api:
            base_url: '%env(CRV_API_BASE_URL)%'

And following that back to the .env  file:

CRV_API_BASE_URL=https://api.codereviewvideos.com

So… what gives?

Well, I found by using a raw string, e.g.:

eight_points_guzzle:
    clients:
        crv_api:
            base_url: 'https://api.codereviewvideos.com'

That yeah, things worked as expected.

And I found that by checking the value of the environment variable inside the running Docker container, that also, yeah, I could see that it was seemingly set:

www-data@c3037e210ca4:~/www.codereviewvideos.com$ echo $CRV_API_BASE_URL
https://api.codereviewvideos.com

My Solution

My solution was to force the use of the string  environment variable processor:

eight_points_guzzle:
    clients:
        crv_api:
            base_url: '%env(string:CRV_API_BASE_URL)%'

And all is right once again in the world.

I wish I understood why that was happening, but I haven’t currently got the time to investigate that further. If you know the root cause, please do share. I’m very curious.

Published by

Code Review

CodeReviewVideos is a video training site helping software developers learn Symfony faster and easier.

One thought on “How I Fixed: Invalid configuration for path base_url: can be: string”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.