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

Invalid string undefined error when producing a message #27

Closed
jobetdelima opened this issue Mar 5, 2018 · 6 comments
Closed

Invalid string undefined error when producing a message #27

jobetdelima opened this issue Mar 5, 2018 · 6 comments

Comments

@jobetdelima
Copy link

jobetdelima commented Mar 5, 2018

Hi,

I've updated this issue (#24 ) with more info. It's not because the topic is not getting created. It's because of an error in the magic-bytes.js code. Was hoping someone familiar with it would know right off the bat what could be going on.

@tobinski
Copy link

I have the similar issue. The schema is fetched from the registry and present. But if I try to encode my values I got a InvalidError.

@tobinski
Copy link

I could resolve the issue in my case. I used Union types in my schema. I have the following schema in the kafka schema registry

const schema = {
  type: 'record',
  namespace: 'com.example',
  name: 'testvalues',
  fields: [
    {name: 'name', type: ['null', 'string'], default: null}
]};

The producer successfully fetches the schema from the registry and failed to encode the value. I passed the value like this: const value = {name: "test"};. This fails. I needed to wrap the value with the correct type: const value = { name: {"string": "test"}}

After I wrapped the UnionTypes I was able to produce data to a topic. On the avcs repo mtth/avsc#20, mtth/avsc#16 you can find some discussion about this topic. Since avcs v4 it should be possible to use Unions more naturally without a wrapping object. But it seems not to work if we call type.encode function directly

@usopan
Copy link

usopan commented May 14, 2018

Any one figured out why wrapping is required to correctly parse the union types?

@thanpolas
Copy link
Contributor

Any one figured out why wrapping is required to correctly parse the union types?

It's just the way union types have been implemented in node.js by avro

@usopan
Copy link

usopan commented May 15, 2018

But if parseOptions.wrapUnions is set to true, it should be handled by the library itself?
Also if that doesn't work how can I get Avro type from a Kafka-avro instance? So that I can use wrapUnions method on our own. Basically this method

@tobinski
Copy link

You just need to set the parseOptions.wrapUnions to false. Then it should work withoput wrapping values. The option is passed to avcs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants