Skip to content

Commit

Permalink
Merge pull request #20146 from BenPope/schema_registry/minus1_is_latest
Browse files Browse the repository at this point in the history
[CORE-3245] schema_registry: Support -1 as latest for get_subject_version
  • Loading branch information
BenPope authored Jun 26, 2024
2 parents 6635762 + 7ac954a commit 7d5611d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/v/pandaproxy/schema_registry/handlers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ result<schema_version> parse_numerical_schema_version(const ss::sstring& ver) {

result<std::optional<schema_version>>
parse_schema_version(const ss::sstring& ver) {
return ver == "latest" ? std::optional<schema_version>{}
: parse_numerical_schema_version(ver).value();
return (ver == "latest" || ver == "-1")
? std::optional<schema_version>{}
: parse_numerical_schema_version(ver).value();
}

ss::future<server::reply_t>
Expand Down
8 changes: 8 additions & 0 deletions tests/rptest/tests/schema_registry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2299,6 +2299,14 @@ def test_post_subjects_subject_versions(self):
assert result["subject"] == f"{topic}-key"
assert result["version"] == 1

self.logger.debug("Get latest (-1) schema version for subject key")
result_raw = self._get_subjects_subject_versions_version(
subject=f"{topic}-key", version="-1", auth=self.super_auth)
assert result_raw.status_code == requests.codes.ok
result = result_raw.json()
assert result["subject"] == f"{topic}-key"
assert result["version"] == 1

self.logger.debug("Get schema version 1")
result_raw = self._get_schemas_ids_id(id=1, auth=self.public_auth)
assert result_raw.json()['error_code'] == 40101
Expand Down

0 comments on commit 7d5611d

Please sign in to comment.