Problem with createDataset
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start with samples/V1/DatasetServiceClient/create_dataset.php and trace the createDataset call into vendor/google/gax/src/RequestBuilder.php:174, where the reported warning occurs. Reproduce the tabular dataset request with the stated PHP and package versions, then verify that the example completes without the foreach warning and creates the dataset.
Written by the indexing model from the issue text.
Description
Environment details
- OS: Windows 10
- PHP version: 8.2.12
- Package name and version: cloud-ai-platform v.1.3
Steps to reproduce
- I'm use the example https://github.com/googleapis/google-cloud-php-ai-platform/blob/main/samples/V1/DatasetServiceClient/create_dataset.php for create a Dataset for Tabular data, when I called the example I have the next error:
foreach() argument must be of type array|object, null given
at vendor\google\gax\src\RequestBuilder.php:174
170▕
171▕ $body = null;
172▕ $queryParams = [];
173▕ $messageData = json_decode($messageDataJson, true);
➜ 174▕ foreach ($messageData as $name => $value) {
175▕ if (array_key_exists($name, $config['placeholders'])) {
176▕ continue;
177▕ }
178▕
1 vendor\google\gax\src\RequestBuilder.php:174
Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}("foreach() argument must be of type array|object, null given", "C:\...\vendor\google\gax\src\RequestBuilder.php")
2 vendor\google\gax\src\RequestBuilder.php:110
Google\ApiCore\RequestBuilder::constructBodyAndQueryParameters(Object(Google\Cloud\AIPlatform\V1\CreateDatasetRequest), ["post", "/v1/{parent=projects/*/locations/*}/datasets", "dataset"])
The code it's the same of the example https://github.com/googleapis/google-cloud-php-ai-platform/blob/main/samples/V1/DatasetServiceClient/create_dataset.php.
Code example
// The called to function are:
$formattedParent = DatasetServiceClient::locationName('lab-ia-430919', 'us-central1');
$this->create_dataset(
$formattedParent,
'example-ventas',
'gs://bucket-ia-example/schemaDatasetVertexAI.yaml'
);
function create_dataset(
string $formattedParent,
string $datasetDisplayName,
string $datasetMetadataSchemaUri
): void {
// Create a client.
$datasetServiceClient = new DatasetServiceClient();
// Prepare the request message.
$datasetMetadata = new Value();
$dataset = (new Dataset())
->setName($datasetDisplayName)
->setDisplayName($datasetDisplayName)
->setMetadataSchemaUri($datasetMetadataSchemaUri)
->setMetadata($datasetMetadata);
$request = (new CreateDatasetRequest())
->setParent($formattedParent)
->setDataset($dataset);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $datasetServiceClient->createDataset($request);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var Dataset $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
- Dominant language
- PHP
- Stars
- 1.2k
- Forks
- 464
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 98
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from googleapis/google-cloud-php
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
googleapis/google-cloud-php#9730 ·
Maintainers usually reply within 1 day
-
type: feature request
Difficulty 1/5 Under an hour Newbie friendliness 75/100
googleapis/google-cloud-php#9716 · 11 reactions ·
Maintainers usually reply within 1 day
-
[Spanner] Retries of UNAVAILABLE errors when resuming a result stream not working properlyPossibly taken @Hectorhammett claimed this today. Open
googleapis/google-cloud-php#9737 · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
googleapis/google-cloud-php#9725 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
googleapis/google-cloud-php#9675 · 1 comment ·
Maintainers usually reply within 1 day
All issues in googleapis/google-cloud-php
Similar issues
-
[Type] Bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
coollabsio/coolify#12016 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
woocommerce/woocommerce-gateway-stripe#6008 ·
Maintainers usually reply within 1 day
-
product / auth product / databases product / sites product / vcs
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
backend enhancement good first issue php
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day