Convert YAML boolean defaults to strings#2232
Convert YAML boolean defaults to strings#2232notAreYouScared merged 1 commit intopelican-dev:mainfrom
Conversation
When importing egg variables, convert boolean default_value entries to 'true'/'false' strings to prevent Laravel from coercing them to 1/0 when saving to TEXT fields. This preserves validation rules like "in:true,false". Implemented by mapping over parsed['variables'] in EggImporterService and normalizing boolean defaults.
📝 WalkthroughWalkthroughAdded a normalization step in EggImporterService::parse to convert boolean default_value entries in YAML-parsed variables to string representations ('true'/'false') to prevent Laravel from storing them as numeric 1/0 in TEXT fields. Changes
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. No actionable comments were generated in the recent review. 🎉 Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where YAML boolean values (true/false) in egg variable default values were being incorrectly converted to integers (1/0) when saved to the database, breaking validation rules like in:true,false that require exact string matches.
Changes:
- Added boolean-to-string conversion logic in
EggImporterService::parse()to convert PHP boolean values to their string representations ("true"/"false") before saving to the database
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Problem:
When importing eggs from YAML format, boolean values (true/false) were being converted to integers (1/0) when saved to the database. This broke validation rules like in:true,false that require exact string matches.
Root Cause:
Symfony YAML parser correctly converts YAML booleans to PHP booleans
Laravel automatically converts PHP booleans to integers when saving to TEXT fields
Result: default_value: true → stored as "1" instead of "true"
Solution:
Added explicit conversion of boolean values to their string representations ("true"/"false") in EggImporterService::parse() before saving to the database.
Impact:
Variables with rules:
in:true,falsenow work correctly after YAML importBackwards compatible: quoted boolean strings in YAML remain unchanged
Only affects actual YAML boolean values (unquoted true/false)