Bird
Raised Fist0

Identify the error in this Kafka Schema Registry usage snippet:

medium📝 Debug Q14 of Q15
Kafka - Schema Registry
Identify the error in this Kafka Schema Registry usage snippet:
schema = '{"type":"record","name":"User","fields":[{"name":"age","type":"int"}]}'
subject = "User-value"
schema_id = client.register_schema(subject, schema)
client.register_schema(subject, schema)
ARegistering the same schema twice causes an error
BNo error; registering same schema returns same ID
CSchema string is not valid JSON
DMissing schema version in registration call
Step-by-Step Solution
Solution:
  1. Step 1: Check schema validity

    The schema string is valid JSON describing a record with an int field.
  2. Step 2: Understand Schema Registry behavior on duplicate schemas

    Registering the same schema again returns the same schema ID without error.
  3. Final Answer:

    No error; registering same schema returns same ID -> Option B
  4. Quick Check:

    Duplicate schema registration returns same ID [OK]
Quick Trick: Duplicate schema registration is safe and returns same ID [OK]
Common Mistakes:
MISTAKES
  • Assuming duplicate registration causes error
  • Thinking schema string is invalid JSON
  • Expecting version parameter in register call

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes