Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix registration validation
Signed-off-by: Lukas Schaefer <[email protected]>
  • Loading branch information
lukasdotcom authored and backportbot[bot] committed Apr 24, 2025
commit 39b49ca307f36c9a28cccc75f93f2581cb8f088a
22 changes: 15 additions & 7 deletions lib/Service/ProvidersAI/TaskProcessingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getExAppTaskProcessingProvider(string $appId, string $name): ?Ta
}
}

private function everyElementHasKeys(array|null $array, array $keys): bool {
private function everyElementHasKeys(array|null $array, array $keys, bool $properties_have_array=true): bool {
if (!is_array($array)) {
return false;
}
Expand All @@ -83,12 +83,20 @@ private function everyElementHasKeys(array|null $array, array $keys): bool {
if (!is_string($propertyName) || !is_array($properties)) {
return false;
}
foreach ($properties as $property) {
if (!is_array($property)) {
return false;
if ($properties_have_array) {
foreach ($properties as $property) {
if (!is_array($property)) {
return false;
}
foreach ($keys as $key) {
if (!array_key_exists($key, $property)) {
return false;
}
}
}
} else {
foreach ($keys as $key) {
if (!array_key_exists($key, $property)) {
if (!array_key_exists($key, $properties)) {
return false;
}
}
Expand All @@ -111,10 +119,10 @@ private function validateTaskProcessingProvider(array $provider): void {
if (!isset($provider['expected_runtime']) || !is_int($provider['expected_runtime'])) {
throw new Exception('"expected_runtime" key must be an integer');
}
if (!$this->everyElementHasKeys($provider['optional_input_shape'], ['name', 'description', 'shape_type'])) {
if (!$this->everyElementHasKeys($provider['optional_input_shape'], ['name', 'description', 'shape_type'], false)) {
throw new Exception('"optional_input_shape" should be an array and must have "name", "description" and "shape_type" keys');
}
if (!$this->everyElementHasKeys($provider['optional_output_shape'], ['name', 'description', 'shape_type'])) {
if (!$this->everyElementHasKeys($provider['optional_output_shape'], ['name', 'description', 'shape_type'], false)) {
throw new Exception('"optional_output_shape" should be an array and must have "name", "description" and "shape_type" keys');
}
if (!$this->everyElementHasKeys($provider['input_shape_enum_values'], ['name', 'value'])) {
Expand Down