laravel-config-validator
laravel-config-validator copied to clipboard
Config validation fails with 2.6.1
Hello,
updated all composer packages today and noticed that the config validation is throwing 210 errors now. Example:
Config validation failed!
210 errors found in your application:
hashing.bcrypt.rounds Value: 12
- hashing.bcrypt.rounds must be an integer.
hashing.argon.memory Value: 65536
- hashing.argon.memory must be an integer.
hashing.argon.threads Value: 1
- hashing.argon.threads must be an integer.
hashing.argon.time Value: 4
- hashing.argon.time must be an integer.
the first example is bcrypt rounds and I haven't overwritten the rounds in my env. I also have a lot of errors where the value has to be a string, but it already is:
mail.mailers.mailgun.transport Value: mailgun
- mail.mailers.mailgun.transport must be a string.
It does not fail with version 2.6.0 and also not with 2.5.0. If you need more information just ping me in a reply please.
Hey @goellner! I'm sorry that you're running into issues with the package. I've just tried reproducing this issue with a fresh Laravel 11 installation like so:
config-validation/hashing.php:
use AshAllenDesign\ConfigValidator\Services\Rule;
return [
Rule::make('bcrypt.rounds')->rules(['required', 'integer']),
Rule::make('argon.memory')->rules(['required', 'integer']),
Rule::make('argon.threads')->rules(['required', 'integer']),
Rule::make('argon.time')->rules(['required', 'integer']),
];
I can't seem to get the validation to fail with what I have there. Would it be possible for you to give me steps to reproduce the issue on a fresh Laravel installation, or maybe provide a fresh Laravel installation that has the error?
Just to double check too, does this still fail after running?:
php artisan optimize:clear
I'll make sure to look at this as a priority today! 😄
Hello Ash - Thanks for the plugin. I use it in all of my applications to ensure correct configuration across environments. It's part of my CI/CD build step to deploy to Vapor.
I get the same issue as @goellner
I am on Laravel 11.7. If I use version 2.6.1 I get 200+ validation errors. I went back to version 2.6.0 and see expected results.
Hey @ronfuller! I'm sorry that you're having issues with the package too. I could never seem to get the package to break in the way that's being described, so I was wondering whether you'd be able to provide a fresh Laravel app repo (with the package installed) that has the issue, please? That'd make things a lot easier for me to investigate the issue 😄
Hi @ash-jc-allen, I just installed the package in a new Laravel app and had the same issues. So I ran the most minimal test possible:
Created a new Laravel app with the latest version (Laravel 11.10.0).
Followed the steps to install the latest version (2.6.1) of your package (composer require, then publish default rulesets).
Ran php artisan config:validate.
It gave me 189 errors. Not surprising that there were some errors, since I didn't do anything else after creating the bare Laravel app (nothing to set up env etc.).
But I then wound back to v2.6.0 of the package:
composer remove ashallendesign/laravel-config-validator
composer require ashallendesign/laravel-config-validator:2.6.0
php artisan vendor:publish --tag=config-validator-defaults
(I realise that last step wasn't necessary - the default rulesets haven't changed.)
This time when I ran php artisan config:validate it only gave me 11 errors.
Same when I went the other way, and upgraded the package to 2.6.1 again: back to 189 errors.
I'm running PHP 8.3.7 on MacOS (the PHP install that comes with Herd). I haven't pushed the repo to Github, but can do so if you'd like ... but there's not much to the test!
Hey @sshead, thanks for this! I think Imight have just realised what's causing the problem (or at least some of it).
I've not updated the defaults for quite a while, so the names of the config fields in them aren't up to date with the names that ship with the Laravel 11 config files. That's definitely something I need to update!
As for the extra errors displaying, I need to take a look at that too. I think it's related to this change here: https://github.com/ash-jc-allen/laravel-config-validator/pull/66
When I was updating the package to work with ashallendesign/short-url (my other package), I noticed that some of the config values weren't being loaded into the validator because of the way I was reading nested fields. So it's possible that the fields were always invalid but in <2.6.0 they weren't being validated so no errors were being thrown. Whereas now, because they're being validated, the errors are showing.
This is just a working theory at the moment though and needs some investigation on my end! Hopefully I can take a look at it some point this week 😄
Created a fresh Laravel 11 installation with the package (2.7.0) here: https://share.zight.com/L1u2xJ4b
php artisan config:validate --files=hashing
Config validation failed!
4 errors found in your application:
hashing.bcrypt.rounds Value: 12
- The hashing.bcrypt.rounds field must be an integer.
hashing.argon.memory Value: 65536
- The hashing.argon.memory field must be an integer.
hashing.argon.threads Value: 1
- The hashing.argon.threads field must be an integer.
hashing.argon.time Value: 4
- The hashing.argon.time field must be an integer.
haven't changed anything from the defaults
tested with php 8.3 and 8.2. same results.
think the issue is that it is getting a string instead of integers?
Hey @goellner! In all fairness, I think a lot of the default rulesets need updating. It's something that's been on my list for a while but it keeps getting pushed down by client work haha!
But yeah, it does look a bit odd that it's marking them as invalid. Maybe that's something for me to investigate over my Christmas break 😄
@ash-jc-allen Any update on this? 🤔
Hey @moritzlang, I'm really sorry, I've not had any time to look at this just yet. Christmas and the beginning of 2025 seemed to be non-stop craziness, so I didn't get any solid time to sit down and investigate 😞
If anyone's open to investigating the issue and putting a PR together, I'd be more than happy to review one 🙂