-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Schema Registry Avro] Remove undefined checks #17714
[Schema Registry Avro] Remove undefined checks #17714
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small remarks, but thanks for following this through!
@@ -202,11 +199,6 @@ export class SchemaRegistryAvroSerializer { | |||
id = (await this.registry.registerSchema(description)).id; | |||
} else { | |||
const response = await this.registry.getSchemaProperties(description); | |||
if (!response) { | |||
throw new Error( | |||
`Schema '${description.name}' not found in registry group '${description.groupName}', or not found to have matching content.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree we need to remove these checks, but I wonder what the dev experience looks like now.
Is the exception that gets bubbled up as easy to understand? Or might it be worth try/catching and throwing some error with this message and the original one as an innerError or something? (Feel free to file an issue for this instead of handling it in this PR)
return mapByContent.get(schema.content); | ||
): Promise<SchemaProperties> { | ||
const result = mapByContent.get(schema.content); | ||
if (result !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use simple truthy for this, can't we?
if (result !== undefined) { | |
if (result) { |
if (result !== undefined) { | ||
return result; | ||
} | ||
throw new Error(`Schema ID not found: ${id}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if inverting the checks would look nicer
if (result !== undefined) { | |
return result; | |
} | |
throw new Error(`Schema ID not found: ${id}`); | |
if (!result) { | |
throw new Error(`Schema ID not found: ${id}`); | |
} | |
return result; |
Closing this for now since I reverted the change to throw and now the client return |
It makes sense after #17700 was merged in.