Skip to content

[Platform] Fatal Error: array_merge() called with string payload in ModelClient implementations #326

@RamyHakam

Description

@RamyHakam

Description:

The ModelClientInterface defines $payload as array|string but many implementations use array_merge($payload, $options) without type checking, causing fatal errors when a string payload is passed.

Affected Files

Multiple ModelClient implementations fail to handle string payloads properly,

Current Behavior

Interface allows: request(Model $model, array|string $payload, array $options = [])
Many implementations call: array_merge($payload, $options)
Result: Fatal error when $payload is string: array_merge(): Expected parameter 1 to be an array, string given

Expected Behavior

All implementations should handle both array and string payloads consistently.
Inconsistent Implementation
Some implementations handle this correctly:

Albert/EmbeddingsModelClient.php:45
Albert/GptModelClient.php:50
Cerebras/ModelClient.php:58

These use: \is_array($payload) ? array_merge($payload, $options) : $payload
Or assigning the payload to ['input => $payload] before merge
But many others don't perform this check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingPlatformIssues & PRs about the AI Platform componentStatus: Needs Review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions