-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[fix][broker] forbid uploading BYTES schema with admin API #18995
[fix][broker] forbid uploading BYTES schema with admin API #18995
Conversation
Codecov Report
@@ Coverage Diff @@
## master #18995 +/- ##
============================================
- Coverage 46.35% 45.88% -0.48%
- Complexity 8939 10369 +1430
============================================
Files 597 711 +114
Lines 56858 69461 +12603
Branches 5905 7453 +1548
============================================
+ Hits 26357 31871 +5514
- Misses 27616 33919 +6303
- Partials 2885 3671 +786
Flags with carried forward coverage won't be shown. Click here to find out more.
|
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiSchemaTest.java
Show resolved
Hide resolved
Oh there is another test case fail... Let me fix it. |
@@ -114,6 +114,10 @@ public CompletableFuture<SchemaVersion> deleteSchemaAsync(boolean authoritative, | |||
} | |||
|
|||
public CompletableFuture<SchemaVersion> postSchemaAsync(PostSchemaPayload payload, boolean authoritative) { | |||
if (SchemaType.BYTES.name().equals(payload.getType())) { | |||
throw new RestException(Response.Status.NOT_ACCEPTABLE, |
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.
Please return failed future to avoid additional try-catch
when invoke this method.
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. Good catch!
+1
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.
Oh, understand, fixed.
/pulsarbot rerun-failure-checks |
if (SchemaType.BYTES.name().equals(payload.getType())) { | ||
return CompletableFuture.failedFuture(new RestException(Response.Status.NOT_ACCEPTABLE, | ||
"Do not upload a BYTES schema, because it's the default schema type")); | ||
} |
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.
How does this work if the schema is not currently bytes and someone wants to change it to bytes?
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.
@michaeljmarshall I think you can delete all the current schemas of the topic. At this time, it's schema defaults to bytes.
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.
BYTES schema doesn't need to upload, when to create producer or consumer with bytes schema, the broker will not check the schema compatibility check
This is a breaking change. |
…pache#18995)" This reverts commit ea4d3b4.
Fixes #18825
Motivation
Admin API can upload
BYTES
schema and store aNONE
schema in the schema registry, which is inconsistent with the client side. After discussion, we decided to forbid users from uploadingBYTES
schema.Mail list: https://lists.apache.org/thread/672zmptfblwjmrf9z8336mk12r7csngf
Modifications
Add a check to reject
BYTES
schema upload.Verifying this change
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: labuladong#17