Skip to content

Feature: allow REST working with SR in read only mode for write#1251

Open
e11it wants to merge 1 commit into
Aiven-Open:mainfrom
e11it:rest-schema-registry-ro-mode
Open

Feature: allow REST working with SR in read only mode for write#1251
e11it wants to merge 1 commit into
Aiven-Open:mainfrom
e11it:rest-schema-registry-ro-mode

Conversation

@e11it
Copy link
Copy Markdown

@e11it e11it commented Apr 1, 2026

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.

@e11it e11it requested a review from a team as a code owner April 1, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant