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

[Schema Registry Avro] Remove undefined checks #17714

Conversation

deyaaeldeen
Copy link
Member

@deyaaeldeen deyaaeldeen commented Sep 16, 2021

It makes sense after #17700 was merged in.

@Azure Azure deleted a comment from check-enforcer bot Sep 16, 2021
Copy link
Member

@xirzec xirzec left a 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.`
Copy link
Member

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) {
Copy link
Member

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?

Suggested change
if (result !== undefined) {
if (result) {

Comment on lines +74 to +77
if (result !== undefined) {
return result;
}
throw new Error(`Schema ID not found: ${id}`);
Copy link
Member

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

Suggested change
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;

@deyaaeldeen
Copy link
Member Author

Closing this for now since I reverted the change to throw and now the client return undefined instead until the archboard revisit that decision given the customer ask for the current behavior.

@deyaaeldeen deyaaeldeen closed this Oct 5, 2021
@deyaaeldeen deyaaeldeen deleted the schema-registry-avro/remove-undefined-checks branch October 5, 2021 20:38
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

Successfully merging this pull request may close these issues.

2 participants