Skip to content

Commit

Permalink
schema_registry: Add error compatibility_not_found
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Pope <[email protected]>
  • Loading branch information
BenPope committed Aug 8, 2023
1 parent df39c83 commit ce64308
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/v/pandaproxy/error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ struct reply_error_category final : std::error_category {
return "subject_version_soft_deleted";
case reply_error_code::subject_version_not_deleted:
return "subject_version_not_deleted";
case reply_error_code::compatibility_not_found:
return "compatibility_not_found";
case reply_error_code::serialization_error:
return "serialization_error";
case reply_error_code::consumer_already_exists:
Expand Down
1 change: 1 addition & 0 deletions src/v/pandaproxy/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ enum class reply_error_code : uint16_t {
subject_not_deleted = 40405,
subject_version_soft_deleted = 40406,
subject_version_not_deleted = 40407,
compatibility_not_found = 40408,
serialization_error = 40801,
consumer_already_exists = 40902,
schema_empty = 42201,
Expand Down
5 changes: 5 additions & 0 deletions src/v/pandaproxy/schema_registry/error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ struct error_category final : std::error_category {
"permanently";
case error_code::subject_version_not_deleted:
return "Version not deleted before being permanently deleted";
case error_code::compatibility_not_found:
return "Subject does not have subject-level compatibility "
"configured";
case error_code::subject_version_operaton_not_permitted:
return "Overwrite new schema is not permitted.";
case error_code::subject_version_has_references:
Expand Down Expand Up @@ -88,6 +91,8 @@ struct error_category final : std::error_category {
return reply_error_code::subject_version_soft_deleted; // 40406
case error_code::subject_version_not_deleted:
return reply_error_code::subject_version_not_deleted; // 40407
case error_code::compatibility_not_found:
return reply_error_code::compatibility_not_found; // 40408
case error_code::subject_schema_invalid:
return reply_error_code::internal_server_error; // 500
case error_code::write_collision:
Expand Down
1 change: 1 addition & 0 deletions src/v/pandaproxy/schema_registry/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum class error_code {
subject_not_deleted,
subject_version_soft_deleted,
subject_version_not_deleted,
compatibility_not_found,
subject_version_operaton_not_permitted,
subject_version_has_references,
subject_version_schema_id_already_exists,
Expand Down
8 changes: 8 additions & 0 deletions src/v/pandaproxy/schema_registry/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,12 @@ inline error_info has_references(const subject& sub, schema_version ver) {
ver())};
}

inline error_info compatibility_not_found(const subject& sub) {
return error_info{
error_code::compatibility_not_found,
fmt::format(
"Subject '{}' does not have subject-level compatibility configured",
sub())};
}

} // namespace pandaproxy::schema_registry
2 changes: 1 addition & 1 deletion src/v/pandaproxy/schema_registry/store.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class store {
} else if (sub_it->second.compatibility) {
return sub_it->second.compatibility.value();
}
return not_found(sub);
return compatibility_not_found(sub);
}

///\brief Set the global compatibility level.
Expand Down
4 changes: 3 additions & 1 deletion tests/rptest/tests/schema_registry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,9 @@ def test_config(self):
self.logger.debug("Get subject config - should fail")
result_raw = self._get_config_subject(subject=f"{topic}-key")
assert result_raw.status_code == requests.codes.not_found
assert result_raw.json()["error_code"] == 40401
assert result_raw.json()["error_code"] == 40408
assert result_raw.json(
)["message"] == f"Subject '{topic}-key' does not have subject-level compatibility configured"

self.logger.debug("Get subject config - fallback to global")
result_raw = self._get_config_subject(subject=f"{topic}-key",
Expand Down

0 comments on commit ce64308

Please sign in to comment.