-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pubsub: Unable to update or clear SchemaSettings #7979
Comments
Thanks for filing this issue. I agree with 1, and it is a bug that we aren't passing in a
This should be correct. We are setting the individual field masks for the sub-fields (e.g. |
Hey @hongalex looks like the fix released as part of thie issue does not fully solve the issue with tc := pubsub.TopicConfigToUpdate{SchemaSettings: &pubsub.SchemaSettings{
LastRevisionID: "",
FirstRevisionID: "",
Schema: fmt.Sprintf("projects/%s/schemas/%s", p.projectID, schemaID),
Encoding: pubsub.EncodingJSON,
}}
_, err = topic.Update(p.ctx, tc) This does not clear the values of the |
Thanks for bringing this up. As making a change to this would necessitate a breaking change to the client library, we don't support clearing individual fields and you must clear the whole schema object. To support clearing these fields, we would have to take in optional First/LastRevisionID, to allow For this specific use case, I recommend using the underlying gRPC library to clear individual Last/FirstRevisionID. For completeness, here's an example of how to do so: import (
...
pubsub "cloud.google.com/go/pubsub/apiv1"
pb "cloud.google.com/go/pubsub/apiv1/pubsubpb"
"google.golang.org/protobuf/types/known/fieldmaskpb"
)
...
ctx := context.Background()
c, err := pubsub.NewPublisherClient(ctx)
if err != nil {
panic(err)
}
// Replace with your topic name.
topicName := "projects/p/topics/t"
topic := &pb.Topic{
Name: topicName,
SchemaSettings: &pb.SchemaSettings{
FirstRevisionId: "",
LastRevisionId: "",
},
}
updateTopicReq := &pb.UpdateTopicRequest{
Topic: topic,
UpdateMask: &fieldmaskpb.FieldMask{
Paths: []string{"schema_settings.first_revision_id", "schema_settings.last_revision_id"},
},
}
_, err = c.UpdateTopic(ctx, updateTopicReq)
if err != nil {
panic(err)
} |
Would it be possible to support this in a future major release? I understand that you would be hesitant to roll out a backwards incompatible change as part of a minor release. |
Although we are considering a major version release of the Pub/Sub client, we are leaning towards only supporting the autogenerated gRPC library ( |
Since discussion seem quiet for now and since the original issue (can't clear) is resolved, I'll close this issue. |
The way
SchemaSettings
messages are added toUpdateTopicRequest
s is incorrect.If you want to clear the
schema_settings
field on a topic, you pass a zero-valuedSchemaSettings
in theTopicConfigToUpdate
struct per this commentHowever, in this section of code which handles that field, it incorrectly passes the empty struct to the
UpdateTopicRequest
when it should benil
in the case where we wish to clear our schema. Also, when we wish to update a field in theSchemaSettings
, we are neglecting to set theschema_settings
update mask path. This section needs to be reworked to:nil
schema_settings
field and theschema_settings
update mask path returned in theUpdateTopicRequest
in the case where we pass a zero-valuedSchemaSettings
in theTopicConfigToUpdate
struct.schema_settings
update mask path when we pass a non-nil
SchemaSettings
in theTopicConfigToUpdate
struct.The text was updated successfully, but these errors were encountered: