Skip to content

Reject non-array data on create_bulk_envs() - #200

Merged
Terrence721 merged 3 commits into
mainfrom
fix/services-bulk-envs-array-validation
Aug 21, 2026
Merged

Reject non-array data on create_bulk_envs()#200
Terrence721 merged 3 commits into
mainfrom
fix/services-bulk-envs-array-validation

Conversation

@Terrence721

Copy link
Copy Markdown
Owner

Summary

Found via a fresh /code-review pass on app/Http/Controllers/Api/ServicesController.php (issue #70).

create_bulk_envs() only checked truthiness of the request's data field before foreach-ing over it (if (! $bulk_data) { ... }). A non-empty string value for data passes the truthiness check but isn't iterable, so foreach ($bulk_data as $item) throws a 500 instead of returning a clean validation error.

Fix

Check is_array($bulk_data) (and non-empty) instead of just truthiness.

Verification

TDD-proved: rejects bulk env creation when data is not an array fails against the pre-fix code (uncaught foreach() argument must be of type array|object, string given) and passes after the fix. All 14 tests in ServicesEnvsTest.php pass. Pint/PHPStan clean on the changed file.

claude and others added 3 commits August 21, 2026 07:17
\$bulk_data = \$request->get('data') only checked truthiness before
foreach-ing over it. A string value for 'data' passed the truthiness
check, then hit foreach() on a non-iterable, throwing a 500 instead
of the intended 400 validation response.
@Terrence721
Terrence721 merged commit ea18e86 into main Aug 21, 2026
9 checks passed
@Terrence721 Terrence721 mentioned this pull request Aug 21, 2026
77 tasks
@Terrence721
Terrence721 deleted the fix/services-bulk-envs-array-validation branch August 21, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants