Feature: allow REST working with SR in read only mode for write#1251
Open
e11it wants to merge 1 commit into
Open
Feature: allow REST working with SR in read only mode for write#1251e11it wants to merge 1 commit into
e11it wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
About this change — What it does
Add rest_lookup_schema_before_register config option (bool, default false) that changes how REST Proxy resolves schema IDs on POST.
When enabled, REST Proxy first calls POST /subjects/{subject} (lookup) before falling back to POST /subjects/{subject}/versions (register). This allows REST Proxy to operate in read-only mode against Schema Registry — it can resolve IDs for pre-registered schemas without needing Write permissions on Subject: resources.
Key changes:
SchemaRegistryClient.lookup_schema()— new method; returns SchemaId on match, None on 404, raises SchemaRetrievalError on other errors.SchemaRegistryClient._build_schema_payload()— extracted shared payload construction from post_new_schema and lookup_schema to eliminate duplication.SchemaRegistrySerializer.upsert_id_for_schema(lookup_first=False)— new parameter; when True, tries lookup before register. Cache behavior unchanged.Why this way
The POST /subjects/{subject} endpoint is the Confluent-compatible way to check if a schema already exists — it returns the schema ID without side effects. By trying lookup first and falling back to register, we keep full backward compatibility (false by default) while enabling a strict read-only SR integration when needed. The fallback ensures no breakage if a schema hasn't been pre-registered yet.
Why we need it
We separate schema registration from schema usage: a dedicated process registers schemas after validating internal standards, while REST Proxy only looks up approved schemas.