Skip to content

[Bug]: PHP warnings in Herd.php when running herd init with extra services (Valkey) #1683

@hazelbag

Description

@hazelbag

Platform

macOS

Operating system version

MacOS Tahoe 26.3.1 (25D2128)

System architecture

ARM64 (M1, M2, etc)

Herd Version

1.28.0 (Build: 64)

PHP Version

No response

Bug description

Running herd init in a project with a herd.yml that includes a valkey extra service produces the following PHP warnings:

Warning: Undefined array key 1 in phar://.../cli/Valet/Herd.php on line 326
Warning: Undefined array key "status" in phar://.../cli/Valet/Herd.php on line 328

The services start correctly, but the warnings are thrown on every herd init. The root cause is in two functions — isExtraServiceRunning and startExtraService in Herd.php — which parse AppleScript responses by splitting on , then : , but do not guard against items that contain no :. When the Valkey service response doesn't match the expected key:value format, $result[1] is undefined and $serviceInfo['status'] doesn't exist.

The fix would be to add null coalescing in both functions, consistent with how other functions in the same file already handle this safely ($result[1] ?? null).

Steps to reproduce

Steps to reproduce:

  1. Create a herd.yml with a valkey service entry
  2. Run herd init in that directory
  3. Observe the PHP warnings printed to the terminal

Relevant log output

Warning: Undefined array key 1 in phar://.../cli/Valet/Herd.php on line 326
Warning: Trying to access array offset on null in phar://.../cli/Valet/Herd.php on line 326
Warning: Undefined array key "status" in phar://.../cli/Valet/Herd.php on line 328

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions