-
Notifications
You must be signed in to change notification settings - Fork 1.2k
DGS-20986 - Modify POST /subjects lookup to fail only if both normalize=true fails #3841
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
Conversation
|
🎉 All Contributor License Agreements have been signed. Ready to merge. |
This comment has been minimized.
This comment has been minimized.
core/src/main/java/io/confluent/kafka/schemaregistry/rest/resources/SubjectsResource.java
Outdated
Show resolved
Hide resolved
| RegisterSchemaRequest request = new RegisterSchemaRequest(); | ||
| request.setSchema(schemaString2); | ||
|
|
||
| io.confluent.kafka.schemaregistry.client.rest.entities.Schema schema = |
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.
Let's add a test case where semantically same schema with normalize=true fails lookup as we are expected not to retry in this case.
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.
But how will semantically same schema with normalize=true fail the lookup? Isnt that what normalization means?
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.
Ah, that's right. I was looking for the test cases
- Semantically same schema but with added spaces/ordering succeeds with normalize=false
- Semantically same schema but with added spaces/ordering succeeds with normalize=true
- Semantically different schema fails with normalize=false
- Semantically different schema fails with normalize=true
I think 2 & 4 are already covered by existing cases, we are good with this.
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.
Semantically same schema but with added spaces/ordering succeeds with normalize=false
Nit: Shouldn't this fail if the ordering is different and normalize=false ?
This comment has been minimized.
This comment has been minimized.
karthikeyanas
left a comment
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.
Get approval from @rayokota as well
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
rayokota
left a comment
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.
Thanks @Nitss10 , LGTM
What
This PR modifies the POST /subjects lookup to handle cases where a client might register a schema with normalize=true while the lookup request is made with normalize=false.
Previously, if a lookup failed with
normalize=false, the API would immediately return an error. This commit changes that logic. It will now only fail the lookup if it fails with both normalize=false and normalize=true. This ensures that clients, like kSQL, can successfully find schemas that were registered using a different normalization setting.The new logic is:
Checklist
Please answer the questions with Y, N or N/A if not applicable.
References
JIRA:
https://confluentinc.atlassian.net/browse/DGS-20986
Test & Review
I've tested the new lookup logic with two scenarios:
Semantically Equivalent Schema: I registered a schema, then changed the field ordering and performed a lookup with normalize=false. As expected, this initial lookup failed. The system then automatically retried with normalize=true and successfully found the schema.
Semantically Different Schema: I attempted a lookup with normalize=true using a semantically different schema. This correctly failed, as the system should not find a match.
This behavior is also fully expressed and validated in the unit test cases.
Open questions / Follow-ups