googleapis / google-cloud-php

Google Cloud Client Library for PHP
https://cloud.google.com/php/docs/reference
Apache License 2.0
1.09k stars 436 forks source link

Field "document" is a required field, but no value is found. #7050

Open traed opened 8 months ago

traed commented 8 months ago

Description

The basic example of creating a document in a Vertex AI datastore fails with the error Field "document" is a required field, but no value is found.. Adding documentId to the actual Document object as well as setting it on the request seems to solve the issue:

$document = new Document([
  'id' => $documentId,
  'json_data' => json_encode([
      'title' => 'Foo'
  ])
]);

Please update your examples. It would also be nice if the docs explains what value [BRANCH] is supposed to have.

Environment details

Steps to reproduce

Run the example from the docs

bshaffer commented 7 months ago

The "problem" is that there is no indication in the protos that "document.id" is required in the DiscoveryEngine protos. Without this, our automatically generated samples don't know that we need to mark it as required.

We use the method_signature annotation to see that it's "recommended" to use document_id in the request, and the samples take advantage of this. You can even use the build method in CreateDocumentRequest.

The nested document ID being required is unfortunate, and it seems to me like it may be a problem in the API.