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

"bidnings.kafka.key" is transformed even if schema is defined as JSON Schema #139

Closed
magicmatatjahu opened this issue Apr 11, 2022 · 4 comments
Labels
bug Something isn't working stale

Comments

@magicmatatjahu
Copy link
Member

Describe the bug

bidnings.kafka.key field is transformed by avro-parser even if schema is defined as JSON Schema, but it should be only when is defined as Avro Schema.

How to Reproduce

Paste to the Studio example spec with bindings.kafka.key:

asyncapi: 2.3.0
info:
  title: Generic title
  version: '0.0.1'
  description: Generic description

channels:
  kafka-topic-name:
    publish:
      message:
        oneOf:
          - name: SessionCreated
            schemaFormat: 'application/vnd.apache.avro;version=1.9.0'
            bindings:
              kafka:
                key:
                  type: string
                  description: Here we go
                  enum: [ 'sessionId' ]
                bindingVersion: '0.2.0'
            payload:
              $ref: '#/components/x-avro-schemas/SessionCreated'

components:
  x-avro-schemas:
    SessionCreated:
      {"namespace": "example.avro",
       "type": "record",
       "name": "User",
       "fields": [
         {"name": "name", "type": "string"},
         {"name": "favorite_number",  "type": ["int", "null"]},
         {"name": "favorite_color", "type": ["string", "null"]}
       ]
      }

and you will see:

image

but it should be (I changed kafka.key to kafka.test):

image

@magicmatatjahu magicmatatjahu added the bug Something isn't working label Apr 11, 2022
@github-actions
Copy link

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@M3lkior
Copy link
Collaborator

M3lkior commented Aug 5, 2022

@magicmatatjahu this is a side effect of the basic support of Avro definition in the key bindings, described here. Should we wait for any progress on your proposal ? or find a workaround to fix this issue like parsing the entire structure to detect if it is a avro or json definition ?

@magicmatatjahu
Copy link
Member Author

magicmatatjahu commented Aug 22, 2022

@M3lkior Sorry for delayed response, I was on vacation.

this is a side effect of the basic support of Avro definition in the key bindings, described #77. Should we wait for any progress on asyncapi/spec#622 ? or find a workaround to fix this issue like parsing the entire structure to detect if it is a avro or json definition ?

I understand, thanks. I don't know when that proposal will be accepted (or even accepted), so I won't count on that. As I see we can check if given schema is avro schema like here https://github.com/asyncapi/avro-schema-parser/blob/master/to-json-schema.js#L271 and make simple try catch for that:

try {
  validateAvroSchema(message.bindings.kafka.key);
} catch(e) {
  // "break" rest of the function
}

but we need to remember that then only JSON Schema will be then accepted.

WDYT?

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

@github-actions github-actions bot added the stale label Dec 21, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

2 participants