Skip to content
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

Proper use of cloudevents avro schema with arrays #1203

Closed
SamlRx opened this issue May 10, 2023 · 8 comments
Closed

Proper use of cloudevents avro schema with arrays #1203

SamlRx opened this issue May 10, 2023 · 8 comments

Comments

@SamlRx
Copy link

SamlRx commented May 10, 2023

We're trying to serialize objects that contain a list of ids contained in an array and I'm having a problem serializing this object using this avro schema (https://github.com/cloudevents/spec/blob/main/cloudevents/formats/cloudevents.avsc)

The message below seems to conform to the schema but the "observer_ids" part seems a bit counter-intuitive to write:

{
      "attribute": {
          "id": "30f25372-323b-47a8-988b-b5b068fb0985",
          "type": "com.some.source.django_service.any_other_models.created",
          "time": "2020-01-01T11:12:00.000000Z",
          "source": "com.a.source",
          "specversion": "1.0",
          "contenttype": "application/json",
          "dataschema": "http://django_service.some.source.com/schema/v1/POST/any_other_models.json"
      },
      "data": {
          "id": "30f25372-323b-47a8-988b-b5b068fb0985",
          "observer_ids": {
              "value":{"observer_ids":[
                  {"value":{"id":1}},
                  {"value":{"id":2}},
                  {"value":{"id":3}}
              ]}
          }
      }
}

Is there a proper way to write an array directly into an Avro message using the schema above?

{
      "attribute": {
          "id": "30f25372-323b-47a8-988b-b5b068fb0985",
          "type": "com.some.source.django_service.any_other_models.created",
          "time": "2020-01-01T11:12:00.000000Z",
          "source": "com.a.source",
          "specversion": "1.0",
          "contenttype": "application/json",
          "dataschema": "http://django_service.some.source.com/schema/v1/POST/any_other_models.json"
      },
      "data": {
          "id": "30f25372-323b-47a8-988b-b5b068fb0985",
          "observer_ids": [1, 2, 3]
        }
}
@duglin
Copy link
Collaborator

duglin commented May 10, 2023

@alexec @JemDay

@JemDay
Copy link
Contributor

JemDay commented May 10, 2023

Not that this helps you right now but I believe it's this type of concern that has resulted in @alexec starting work on a modified Avro format.

Ref: GH-1197

Note: As it currently stands that proposal only allows for byte[] as a data payload - if you see that as an issue now would be a good time to flag that.

@duglin
Copy link
Collaborator

duglin commented Jun 1, 2023

@SamlRx have you look at Alex's PR? #1197 does that help you at all?

@github-actions
Copy link

github-actions bot commented Jul 2, 2023

This issue is stale because it has been open for 30 days with no
activity. Mark as fresh by updating e.g., adding the comment /remove-lifecycle stale.

@duglin
Copy link
Collaborator

duglin commented Jul 6, 2023

@github-actions
Copy link

github-actions bot commented Aug 7, 2023

This issue is stale because it has been open for 30 days with no
activity. Mark as fresh by updating e.g., adding the comment /remove-lifecycle stale.

@duglin
Copy link
Collaborator

duglin commented Sep 21, 2023

@SamlRx I'm going to suggest we close this since I'm not getting a response to the questions. Please let us know if this problem still exists since the other PR was merged.

@duglin
Copy link
Collaborator

duglin commented Sep 21, 2023

Agreed on the 9/21 call to close this issue. If someone would like to reopen it and push it forward please let us know.

@duglin duglin closed this as completed Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants