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

[v24.2.x] [CORE-7039] schema_registry: Tolerate null metadata and ruleSet #23078

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/v/pandaproxy/schema_registry/requests/post_subject_versions.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class post_subject_versions_request_handler
schema,
id,
version,
metadata,
ruleset,
schema_type,
references,
reference,
Expand Down Expand Up @@ -74,6 +76,8 @@ class post_subject_versions_request_handler
.match("schema", state::schema)
.match("id", state::id)
.match("version", state::version)
.match("metadata", state::metadata)
.match("ruleSet", state::ruleset)
.match("schemaType", state::schema_type)
.match("references", state::references)
.default_match(std::nullopt)};
Expand All @@ -97,6 +101,8 @@ class post_subject_versions_request_handler
case state::schema:
case state::id:
case state::version:
case state::metadata:
case state::ruleset:
case state::schema_type:
case state::references:
case state::reference_name:
Expand All @@ -107,6 +113,28 @@ class post_subject_versions_request_handler
return false;
}

bool Null() {
switch (_state) {
case state::metadata:
case state::ruleset:
_state = state::record;
return true;
case state::empty:
case state::record:
case state::schema:
case state::id:
case state::version:
case state::schema_type:
case state::references:
case state::reference:
case state::reference_name:
case state::reference_subject:
case state::reference_version:
break;
}
return false;
}

bool Uint(int i) {
switch (_state) {
case state::id: {
Expand All @@ -127,6 +155,8 @@ class post_subject_versions_request_handler
case state::empty:
case state::record:
case state::schema:
case state::metadata:
case state::ruleset:
case state::schema_type:
case state::references:
case state::reference:
Expand Down Expand Up @@ -170,6 +200,8 @@ class post_subject_versions_request_handler
case state::record:
case state::id:
case state::version:
case state::metadata:
case state::ruleset:
case state::references:
case state::reference:
case state::reference_version:
Expand All @@ -193,6 +225,8 @@ class post_subject_versions_request_handler
case state::schema:
case state::id:
case state::version:
case state::metadata:
case state::ruleset:
case state::schema_type:
case state::reference:
case state::reference_name:
Expand Down Expand Up @@ -222,6 +256,8 @@ class post_subject_versions_request_handler
case state::schema:
case state::id:
case state::version:
case state::metadata:
case state::ruleset:
case state::schema_type:
case state::references:
case state::reference_name:
Expand Down
28 changes: 28 additions & 0 deletions tests/rptest/tests/schema_registry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,34 @@ def test_post_subjects_subject_versions_version_many(self):
assert result_raw.status_code == requests.codes.ok
assert result_raw.json()["id"] == 1

@cluster(num_nodes=3)
def test_post_subjects_subject_versions_metadata_ruleset(self):
"""
Verify posting a schema with metatada and ruleSet
These are not supported, but if they're null, we let it pass.
"""

topic = create_topic_names(1)[0]

self.logger.debug("Dump the schema with null metadata and ruleSet")
schema_1_data = json.dumps({
"schema": schema1_def,
"metadata": None,
"ruleSet": None
})

self.logger.debug("Posting schema as a subject key")
result_raw = self._post_subjects_subject_versions(
subject=f"{topic}-key", data=schema_1_data)
self.logger.debug(result_raw)
assert result_raw.status_code == requests.codes.ok

self.logger.debug("Retrieving schema")
result_raw = self._post_subjects_subject(subject=f"{topic}-key",
data=schema_1_data)
self.logger.debug(result_raw)
assert result_raw.status_code == requests.codes.ok

@cluster(num_nodes=3)
def test_post_subjects_subject(self):
"""
Expand Down
Loading