Skip to content

Fix the MappingProxyType error when converting schema to JSON #930

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

Merged

Conversation

choogeboom
Copy link

@choogeboom choogeboom commented Aug 10, 2020

avro.schema.Schema.to_json uses MappingProxyType, which is not compatible with json.dumps. This PR solves the issue in the same way that the avro library solves it, by using the MappingProxyEncoder in the avro library. Unfortunately that was causing appveyor to fail, so I'm just converting to JSON with the str function, which is the same under the hood.

fixes #610

@ghost
Copy link

ghost commented Aug 10, 2020

@confluentinc It looks like @hoogamaphone just signed our Contributor License Agreement. 👍

Always at your service,

clabot

@choogeboom choogeboom changed the title Use the MappingProxyEncoder to encode the JSON Fix the MappingProxyType error when converting schema to JSON Aug 10, 2020
Copy link

@Incognito Incognito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey folks, this is an easy way to fix an entire broken feature. Can we get eyes on it?

@choogeboom
Copy link
Author

I've given up hope on this PR, and migrated my code to start using SchemaRegistryClient instead, which sidesteps this whole issue.

@Incognito
Copy link

We did this too actually, but it was a shame that my team had to re-work large parts of their work because of it.

@edenhill edenhill added the component:serdes Avro, JSON, Protobof, Schema-registry label Mar 9, 2021
@mhowlett
Copy link
Contributor

I'm just converting to JSON with the str function, which is the same under the hood.

https://github.com/apache/avro/blob/master/lang/py3/avro/schema.py#L219

Copy link
Contributor

@mhowlett mhowlett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (hopefully not missing anything important)

@mhowlett mhowlett merged commit c623c68 into confluentinc:master Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:serdes Avro, JSON, Protobof, Schema-registry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

confluent-kafka 1.0.0 is incompatible with avro-python3 1.9.0
4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy