Schema Registry (Confluent REST API): implementation reference
How the Confluent-compatible Schema Registry listener is built: HTTP handling, authentication, the route table, schema identity and compatibility for Avro, Protobuf and JSON Schema, storage, errors, limits and tests. For the proof scores, how to connect and how to re-run the differential suite, see the operator page Schema Registry. The Kafka broker that serializers pair it with is in Kafka. Authentication policy across all wires is in Security.
1. Source layout
| File | Role |
|---|---|
src/protocol/schema_registry/mod.rs |
SchemaRegistryHandler: listener, HTTP/1.1 parsing, auth policy, routing, registration, deletes, config and mode, persistence to SQL tables |
src/protocol/schema_registry/avro.rs |
Port of the parts of Apache Avro 1.11 the registry uses: Schema.parse with its error messages, Schema.toString canonical form, reader/writer compatibility |
src/protocol/schema_registry/protobuf.rs |
.proto text and base64 FileDescriptorProto parsing, Confluent's printed .proto form, Confluent SchemaDiff rules |
src/protocol/schema_registry/jsonschema.rs |
JSON Schema compatibility modelled on Confluent's everit-based diff |
src/protocol/schema_registry/json.rs |
Order-preserving JSON parser and printer with Jackson-style number output |
The listener is a hand-written HTTP/1.1 server on Tokio; it does not use hyper. Third-party crates used here: prost and prost-types (descriptor decoding), base64. The module carries its own JSON type because serde_json without preserve_order sorts object keys, which would change schema text and therefore ids. (source: src/protocol/schema_registry/json.rs, module comment; src/protocol/schema_registry/protobuf.rs, use lines)
2. Transport
- Port:
[server] schema_registry_port, default 8081. When TLS is configured,TlsListener::accept_autoaccepts HTTPS and plain HTTP on the same port. (source:src/config.rs,ServerConfig::default;src/protocol/schema_registry/mod.rs,with_tls,start) - Each connection is served in a loop until EOF or
Connection: close. Requests are read line by line: request line, headers (names lowercased), then a body only whenContent-Lengthis present.Transfer-Encoding: chunkedis not read, so a chunked body is ignored. (source:src/protocol/schema_registry/mod.rs,handle_connection,parse_request) -
MAX_HTTP_BODYis 16 MiB. A larger declaredContent-Lengthcloses the connection without a response. The body is read before the authentication check. (source:src/protocol/schema_registry/mod.rs,MAX_HTTP_BODY,parse_request,handle_connection;docs/status/2026-11-29-preauth-body-limits.mdas cited in Security) - Every response has
Content-Type: application/vnd.schemaregistry.v1+json, including the/schemaendpoints that return raw schema text. A 401 also carries aWWW-Authenticatechallenge. (source:src/protocol/schema_registry/mod.rs,CONTENT_TYPE,HttpResponse::encode) - Path segments and query values are percent-decoded; a query key with no
=counts astrue. (source:src/protocol/schema_registry/mod.rs,Target::parse,percent_decode)
Not verified: no test covers TLS, chunked bodies or the body cap on this wire.
3. Authentication
The policy is read from SYNERGYDB_SCHEMA_REGISTRY_AUTH at handler construction and applied per connection by peer address:
| Value | Policy | Who must authenticate |
|---|---|---|
| unset or anything else (default) | LocalOnly |
Clients not on loopback (IPv4, IPv6 or IPv4-mapped) |
users, basic, on, required, true, 1
|
Users |
Every client |
open, off, none, no, false, 0
|
Open |
Nobody |
unset, with SYNERGYDB_DEV_INSECURE_AUTH on |
Open |
Nobody |
(source: src/protocol/schema_registry/mod.rs, SrAuth::parse, SrAuth::requires, auth_from_env, start; src/auth/wire_auth.rs, is_loopback) Tested by default_is_open_to_loopback_only and explicit_settings in src/protocol/schema_registry/mod.rs.
When a connection must authenticate, every request except GET / needs Authorization: Basic base64(user:password), checked by authorize_http_basic_for("schema_registry", ...): a catalog role and password, and the role must be a superuser or a member of synergy_wire_schema_registry or synergy_wire_all (unless SYNERGYDB_WIRE_ACCESS is open, off or any). A missing header is accepted only when SYNERGYDB_DEV_INSECURE_AUTH is on. A refusal is 401 with Confluent's body {"error_code":40101,"message":"Unauthorized"}. (source: src/protocol/schema_registry/mod.rs, authorized, handle_connection; src/auth/wire_auth.rs, authorize_http_basic_for, verify_wire_credential) Tested by requests_without_valid_credentials_are_refused in tests/protocol_schema_registry.rs and schema_registry_rejects_unauthenticated_requests in tests/wire_preauth_gate.rs.
There is no per-subject authorization: an authenticated principal can read, register and delete under every subject. Unauthenticated loopback requests run with no user identity. (source: src/protocol/schema_registry/mod.rs, route)
Audit: when the audit log is on, every request is recorded with wire schema_registry, method, path, HTTP status and the subject (or id:<n>) as the object. POST /subjects/{subject} (a lookup) is classed as a read. (source: src/protocol/schema_registry/mod.rs, handle_connection) Not verified: no test of the audit records was found.
4. Endpoints
The complete route table from SchemaRegistryHandler::route. A known path with another method answers 405 (error_code 405); any other path answers 404. (source: src/protocol/schema_registry/mod.rs, route)
| Method | Path | Behaviour |
|---|---|---|
| GET | / |
{} (health probe; never needs auth) |
| GET | /schemas/types |
["JSON","PROTOBUF","AVRO"] |
| GET | /contexts |
["."] (only the default context) |
| GET | /v1/metadata/id |
Fixed scope: kafka-cluster = synergydb, schema-registry-cluster = schema-registry
|
| GET | /subjects |
Subject names; subjectPrefix, deleted, deletedOnly
|
| GET | /subjects/{s}/versions |
Version numbers; deleted includes soft-deleted |
| GET | /subjects/{s}/versions/{v} |
{subject, version, id, [schemaType], [references], schema}; {v} is a number or latest (also -1) |
| GET | /subjects/{s}/versions/{v}/schema |
Raw schema text |
| GET | /subjects/{s}/versions/{v}/referencedby |
Ids of schemas that reference this version |
| POST | /subjects/{s}/versions |
Register (section 5); returns {"id": n}
|
| POST | /subjects/{s} |
Look up a schema under a subject; deleted searches soft-deleted versions; 40403 if absent |
| DELETE | /subjects/{s} |
Soft delete every live version; permanent=true hard-deletes a subject already soft-deleted; returns the version list |
| DELETE | /subjects/{s}/versions/{v} |
Soft or (permanent=true) hard delete of one version; returns the version |
| GET | /schemas |
Every version as a version object; subjectPrefix, deleted, latestOnly
|
| GET | /schemas/ids/{id} |
{[schemaType], schema, [references]} |
| GET | /schemas/ids/{id}/schema |
Raw schema text |
| GET | /schemas/ids/{id}/subjects |
Subjects using the id; deleted
|
| GET | /schemas/ids/{id}/versions |
[{subject, version}] using the id; deleted
|
| POST | /compatibility/subjects/{s}/versions |
Check against the versions the subject's level names (latest, or all for _TRANSITIVE); {"is_compatible": bool}, verbose=true adds messages
|
| POST | /compatibility/subjects/{s}/versions/{v} |
Check against one version |
| GET | /config |
{"compatibilityLevel": ...}, global (default BACKWARD) |
| GET | /config/{s} |
Subject level; defaultToGlobal=true falls back; otherwise 40408 when unset |
| PUT |
/config, /config/{s}
|
{"compatibility": level}; 42203 for an unknown level |
| DELETE | /config |
Reset global; returns the old level |
| DELETE | /config/{s} |
Remove a subject's level; 40401 when none was set |
| GET |
/mode, /mode/{s}
|
{"mode": ...}, default READWRITE; subject form 40409 when unset unless defaultToGlobal=true
|
| PUT |
/mode, /mode/{s}
|
{"mode": m} with READWRITE, READONLY, READONLY_OVERRIDE or IMPORT; 42204 otherwise |
| DELETE | /mode/{s} |
Remove a subject's mode |
(source: src/protocol/schema_registry/mod.rs, route, register, delete_subject, delete_version, version_json)
There is no DELETE /mode (global) route, and none of Confluent's /exporters, /dek-registry, /keks or rule-set endpoints exist; they answer 404. (source: src/protocol/schema_registry/mod.rs, route)
Tested by register_and_read_back_by_id_and_version, missing_things_use_confluent_error_codes, delete_subject_returns_its_versions_and_removes_it and compatibility_config_is_validated_and_scoped in tests/protocol_schema_registry.rs.
5. Registration
(source: src/protocol/schema_registry/mod.rs, register, candidate, read_only, check_against)
-
Schema types.
schemaTypeisAVRO(default),PROTOBUForJSON; anything else is 42201 "Invalid schema type". (source:src/protocol/schema_registry/mod.rs,candidate) -
Canonical form and identity. Two submissions are the same schema when type, canonical text and references match (
same). Avro text is canonicalized to Avro'sSchema.toString()form, so the same schema written with other whitespace or key order gets the same id. JSON Schema text is re-printed compactly with keys in written order. Protobuf is stored as the.prototext Confluent prints (sections in fixed order, each after a blank line), whether it arrived as text or as a base64FileDescriptorProto. (source:src/protocol/schema_registry/mod.rs,candidate,same;src/protocol/schema_registry/avro.rs, module comment;src/protocol/schema_registry/protobuf.rs, module comment) Tested bycanonical_matches_confluentinavro.rs,canonical_text_matches_confluent_layoutanddescriptor_round_tripinprotobuf.rs, andkeeps_key_order_and_java_numbersinjson.rs. -
Ids are global. An id is reused while some subject version, soft-deleted ones included, still points at an identical schema; otherwise the next id is one more than the highest id ever stored, so ids are never handed out twice. (source:
src/protocol/schema_registry/mod.rs,register,State::schema_in_use) -
Versions continue after soft deletes (
max version + 1). Registering a schema that a soft-deleted version of the same subject holds removes that version for good, as Confluent does. (source:src/protocol/schema_registry/mod.rs,register,hard_delete) -
References: each reference is
{name, subject, version}; a null version is an error and-1means the subject's latest live version. Avro references are resolved by loading the referenced subject version's schema as named types. (source:src/protocol/schema_registry/mod.rs,candidate,State::parse_avro,State::load_ref) - Error messages for invalid Avro reproduce Avro's parser messages, which Confluent returns verbatim; invalid JSON reproduces Jackson-style messages. (source:
src/protocol/schema_registry/avro.rs, module comment;src/protocol/schema_registry/json.rs) Tested byparse_errors_match_avroandjackson_style_errors.
Compatibility
The level is the subject's own, else the global level, else BACKWARD. NONE accepts anything. A non-transitive level checks the latest live version only; a _TRANSITIVE level checks every live version, newest first, and stops at the first that fails. BACKWARD runs the check with the new schema as reader, FORWARD with the old schema as reader, FULL both. Messages follow Confluent's layout: forward messages first, then {oldSchemaVersion: n} and {oldSchema: '...'} (only from the backward check, or for FORWARD alone), then {validateFields: 'false', compatibility: 'LEVEL'}. (source: src/protocol/schema_registry/mod.rs, compat_messages, directional, register)
| Type | Rules |
|---|---|
| Avro | Avro's SchemaCompatibility.checkReaderWriterCompatibility: type mismatch, reader field missing a default, missing enum symbols, missing union branch, name mismatch, fixed size mismatch, reported with Confluent's wording (difference) |
| Protobuf | Confluent SchemaDiff: package changed, message removed, scalar kind changed (with the wire-compatible groups), field kind and named type changed, oneof field removed, fields moved into a oneof, proto2 required fields added or removed |
| JSON Schema | Confluent's everit-based diff: type changed or narrowed, string, number, array and object bounds added or tightened, pattern added, enums, anyOf widening, open and closed content models, additionalProperties, required properties |
(source: src/protocol/schema_registry/mod.rs, difference; src/protocol/schema_registry/avro.rs, check; src/protocol/schema_registry/protobuf.rs, incompatibilities; src/protocol/schema_registry/jsonschema.rs, incompatibilities; docs/status/2026-11-30-schema-registry-protobuf-json-compat.md) Tested by compatibility_matches_avro in avro.rs, scalar_kind_change_is_incompatible in protobuf.rs, and type_change_and_narrowing and open_and_closed_content_models in jsonschema.rs.
A schema of one type is never compared with a stored schema of another type (directional returns no differences), so changing a subject's schema type passes every level. (source: src/protocol/schema_registry/mod.rs, directional) Not verified: no test covers a type change; Confluent's behaviour for this case was not checked.
Known gaps recorded by the status entry: JSON Schema $ref targets are compared by reference string, not resolved, and dependencies, patternProperties and if/then/else are not compared; for Protobuf, a descriptor's json_name is printed only when it differs from the default and custom extension options inside a descriptor are not printed. (source: docs/status/2026-11-30-schema-registry-protobuf-json-compat.md)
Modes and deletes
-
READONLYandREADONLY_OVERRIDE(subject mode, else global) refuse registration and both delete routes with 422 / 42205. They do not blockPUT /configorPUT /mode. (source:src/protocol/schema_registry/mod.rs,read_only,register,delete_subject,delete_version) -
IMPORTis accepted as a mode value, but registration does not take an explicit id: Not wired: IMPORT-mode registrations with explicit ids are not implemented (module comment). (source:src/protocol/schema_registry/mod.rs, module comment,register) - Deletes are soft first. A permanent delete of a live subject or version is 40405 or 40407; a soft delete of an already soft-deleted one is 40404 or 40406. A version that another schema references cannot be deleted (422 / 42206). (source:
src/protocol/schema_registry/mod.rs,delete_subject,delete_version,referenced_error)
6. Storage
The registry's contents are ordinary SynergyDB tables, created at startup with CREATE TABLE IF NOT EXISTS through a QueryEngine on the shared storage engine:
| Table | Columns | Holds |
|---|---|---|
_sr_schemas |
id (PK), schema_text, schema_type
|
Every schema ever registered |
_sr_subjects |
subject, version (PK), schema_id
|
Subject versions |
_sr_deleted |
subject, version (PK) |
Soft-delete markers |
_sr_refs |
schema_id, pos (PK), ref_name, ref_subject, ref_version
|
References |
_sr_config |
cfg_key (PK), cfg_value
|
compat:<subject> and mode:<subject>; the global entry uses the subject __global__
|
(source: src/protocol/schema_registry/mod.rs, with_storage, set_cfg, GLOBAL)
- At startup every row is loaded into an in-memory
State(schemas, subjects with deleted flags, compatibility and mode maps) behind one mutex; every request is answered from that state while holding the lock. Older rows are normalized on load: Avro text without references is re-canonicalized and Protobuf text is re-printed. (source:src/protocol/schema_registry/mod.rs,with_storage,State,route) - Each change runs one or more SQL statements built with single quotes doubled (
esc) throughexec. The statements are separate, not one transaction, and a failure is only printed to stderr; the HTTP response still reports success and the in-memory state keeps the change. (source:src/protocol/schema_registry/mod.rs,exec,register,hard_delete,soft_delete) Not verified: no test covers a failed or partial write. - Rows changed directly over a SQL wire are not seen by the registry until a restart, because the tables are read only in
with_storage, and the module registers no cluster replica listener. (source:src/protocol/schema_registry/mod.rs,with_storage) Not verified: no test covers SQL-side edits or multi-node use.
Restart durability is covered by the differential suite's restart phase (1/1) and by the ksqlDB check after kill -9 reported on the operator page.
7. Errors
Errors use Confluent's body {"error_code": n, "message": "..."} with the matching HTTP status:
| HTTP | error_code |
When |
|---|---|---|
| 400 | 400 | Request body is not valid JSON (first line of the parser message) |
| 401 | 40101 | Authentication required and missing or wrong |
| 404 | 40401 | Subject not found |
| 404 | 40402 | Version not found |
| 404 | 40403 | Schema not found |
| 404 | 40404 / 40406 | Subject / version was soft-deleted (permanent=true needed) |
| 404 | 40405 / 40407 | Subject / version not soft-deleted before a permanent delete |
| 404 | 40408 | Subject has no compatibility level |
| 404 | 40409 | Subject has no mode |
| 404 | 404 | Unknown path |
| 405 | 405 | Known path, unsupported method |
| 409 | 409 | Incompatible schema |
| 422 | 42201 | Invalid or empty schema, invalid schema type, bad reference |
| 422 | 42202 | Invalid version string |
| 422 | 42203 | Invalid compatibility level |
| 422 | 42204 | Invalid mode |
| 422 | 42205 | Subject in read-only mode |
| 422 | 42206 | Version is referenced by another schema |
(source: src/protocol/schema_registry/mod.rs, HttpResponse::err, subject_not_found, version_not_found, bad_version, not_found, route, register, delete_subject, delete_version) Tested in part by missing_things_use_confluent_error_codes.
8. Configuration and limits
| Key / variable | Default | Effect |
|---|---|---|
[server] schema_registry_port |
8081 | Listener port; unset disables the wire |
| TLS settings | off | HTTPS on the same port (first-byte detection) |
SYNERGYDB_SCHEMA_REGISTRY_AUTH |
loopback open |
users or open (section 3) |
SYNERGYDB_DEV_INSECURE_AUTH |
unset | Default policy becomes Open; missing credentials accepted |
SYNERGYDB_WIRE_ACCESS |
enforced |
open/off/any drops the synergy_wire_schema_registry check |
MAX_HTTP_BODY (constant) |
16 MiB | Larger bodies close the connection |
(source: src/config.rs, ServerConfig; src/server/mod.rs; src/protocol/schema_registry/mod.rs)
Not implemented: contexts other than the default (/contexts lists only ., and context-qualified subjects such as :.ctx:subject are treated as plain subject names), IMPORT-mode registrations with explicit ids, schema metadata and rule sets (always null in error text, never stored), and the normalize and format query parameters. (source: src/protocol/schema_registry/mod.rs, module comment, route, candidate)
9. Tests and proof evidence
| Where | What |
|---|---|
tests/protocol_schema_registry.rs (5 tests) |
A real handler on TCP: refused credentials, register and read back by id and version, Confluent error codes, subject delete, compatibility config validation and scope |
tests/wire_preauth_gate.rs |
schema_registry_rejects_unauthenticated_requests |
| Unit tests |
mod.rs 2 (auth policy), avro.rs 3, protobuf.rs 3, jsonschema.rs 2, json.rs 2 |
docs/proof/2026-11-30/proof-pack-a3232c9/logs/schema-registry-schema-registry-diff.txt |
Differential against Confluent Schema Registry 7.7: 277/277 (single connection 275, second connection 1, after restart 1) |
docs/status/2026-11-30-schema-registry-protobuf-json-compat.md |
Protobuf and JSON Schema compatibility battery 59/59; confluent-kafka Avro, Protobuf and JSON Schema app 45/45, also with SASL/PLAIN and Basic auth |
docs/status/2026-11-30-gremlin-sr-real-apps.md |
ksqlDB 7.7.1 AVRO streams and tables against SynergyDB |
The proof pack's report.md still lists "JSON Schema and Protobuf compatibility is not checked (every change is accepted)" as a known gap. That is stale: the code checks both (section 5) and the status entry of the same date records the change. The scripts behind the app and battery results (test-scripts/schema-registry-app/, test-scripts/schema-registry-ksqldb/) are not in the reviewed snapshot.