Skip to content

Extract validateSchema into overridable hook on AbstractSchemaRegistry#4278

Open
Toluwa Jibodu (djibodu) wants to merge 1 commit into
8.0.xfrom
extract-validate-schema-hook
Open

Extract validateSchema into overridable hook on AbstractSchemaRegistry#4278
Toluwa Jibodu (djibodu) wants to merge 1 commit into
8.0.xfrom
extract-validate-schema-hook

Conversation

@djibodu
Copy link
Copy Markdown
Contributor

@djibodu Toluwa Jibodu (djibodu) commented Apr 23, 2026

Summary

  • Extract the parsedSchema.validate(...) call out of maybeValidateAndNormalizeSchema into a new protected void validateSchema(ParsedSchema, Schema, Config) on AbstractSchemaRegistry. Default implementation preserves the existing IMPORT-mode gate, so behavior is bit-identical for every current caller.
  • Same shape as the recent Extract association logic and Extract store query logic into overridable hooks commits on this branch.

Semantics

  • parsedSchema.validate(...) has exactly one call site in AbstractSchemaRegistry (the one being moved). All four callers of canonicalizeSchema route through maybeValidateAndNormalizeSchema → the new hook.
  • KafkaSchemaRegistry is the only in-repo subclass and doesn't override canonicalizeSchema in a way that touches validation. The maybeValidateAndNormalizeSchema method is private and cannot be overridden, so the hook is purely additive.
  • Only subclasses that opt in see different behavior.

Test plan

  • AbstractSchemaRegistryTest — new file. Asserts (a) the default hook is invoked during register(...), and (b) a subclass that throws from validateSchema causes registration to fail with the thrown message wrapped in InvalidSchemaException. Documents the extension point and locks the contract.
  • Existing core tests — unchanged; no behavior drift expected.
  • Local mvn -pl core test hit a CodeArtifact dependency-resolution error (kafka-schema-registry-client:8.0.5-0 cached-miss in third-party-artifacts), so the suite was not run locally. Relying on CI.

🤖 Generated with Claude Code

Move the parsedSchema.validate(...) call out of maybeValidateAndNormalizeSchema
into a protected validateSchema(ParsedSchema, Schema, Config) method. The
default implementation preserves the existing IMPORT-mode gate, so behavior is
bit-identical for every current caller. Subclasses can now override the hook to
alter validation semantics (e.g. migration replay paths that must not re-run
validate on already-persisted schemas).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@djibodu Toluwa Jibodu (djibodu) requested a review from a team as a code owner April 23, 2026 17:49
@confluent-cla-assistant
Copy link
Copy Markdown

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

@akhileshm1
Copy link
Copy Markdown
Member

do we still need this given what we discovered yesterday Toluwa Jibodu (@djibodu) ?

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.

2 participants