question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Azure schema registry SDK does not have a "schema does not exist" return value

See original GitHub issue

Is your feature request related to a problem? Please describe.

When retrieving a schema with a method like SchemaRegistryClient.getSchemaId or SchemaRegistryClient.getSchemaById, an error is thrown if the schema does not exists.

This does not leave me with a clear way to differentiate a functional error (the schema doesn’t exists) from a technical errors (like ‘there is no network connection’ or’ you are not authorized to retrieve schemas’)

Describe the solution you’d like

The current signature of these 2 methods is:

getSchemaId(schema: SchemaDescription, options?: GetSchemaIdOptions): Promise<SchemaId>;
getSchemaById(id: string, options?: GetSchemaByIdOptions): Promise<Schema>;

A more natural return type would be one that encapsulates functional errors, for example

getSchemaId(schema: SchemaDescription, options?: GetSchemaIdOptions): Promise<SchemaId | null>;
getSchemaById(id: string, options?: GetSchemaByIdOptions): Promise<Schema | null>;

Describe alternatives you’ve considered

A return type like Promise<Schema | { error: 'notfound', content: '...' }> is more informative, but would not work with the widely used error handling patterns in Javascript like

const id = getSchemaById(...)
if(!id) {
  ...
}

If breaking backwards compatibility is not desired, I’d settle for having a fixed and documented behaviour about how one should check for this error, for example by ensuring the resulting Error in the rejected promise will always have a { statusCode: 404 } field like it does now.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nguerreracommented, May 6, 2021

#15149 is out for review with that approach

1reaction
xirzeccommented, May 5, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

azure.schemaregistry.SchemaRegistryClient class
SchemaRegistryClient is a client for registering and retrieving schemas from the Azure Schema Registry service.
Read more >
azure.schemaregistry package - NET
Register new schema. If schema of specified name does not exist in specified group, schema is created at version 1. If schema of...
Read more >
Schema Registry API Reference | Confluent Documentation
If the primary is not available, the client will get an error code indicating that the forwarding has failed. If no schemaType is...
Read more >
Azure Schema Registry with Event Hubs and Kafka
// registered if it does not already exist. return new KafkaAvroAsyncSerializer<CustomerLoyalty>(. schemaRegistryUrl,.
Read more >
Event Streams schema registry - IBM Cloud Docs
The schemas do not need to be transferred in the messages this way, ... registry API. The Schema Registry is not available for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found