Skip to content

CORE-16246 schema_registry/avro: collapse primitive type objects#30565

Open
pgellert wants to merge 1 commit into
redpanda-data:devfrom
pgellert:sr/avro-primitive-collapse-minimal
Open

CORE-16246 schema_registry/avro: collapse primitive type objects#30565
pgellert wants to merge 1 commit into
redpanda-data:devfrom
pgellert:sr/avro-primitive-collapse-minimal

Conversation

@pgellert
Copy link
Copy Markdown
Contributor

Redpanda Schema Registry did not treat Avro primitive object schemas like
{"type":"string"} as equivalent to the simple primitive form "string"
when they appeared inside nested schemas. This caused schema lookup to
return 40403 Schema not found when a stored schema used the verbose form
but the lookup payload used the equivalent simple form.

This PR collapses primitive object schemas to the simple form while walking
actual Avro schema values: record field types, array items, map values,
union branches, and top-level primitive schemas. Custom metadata that happens
to look like a primitive schema is left unchanged.

Fixes https://redpandadata.atlassian.net/browse/CORE-16246
Fixes https://redpandadata.atlassian.net/browse/CORE-16247

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v26.1.x
  • v25.3.x
  • v25.2.x

Release Notes

Bug Fixes

  • Fixed Avro schema lookup false negatives when equivalent nested primitive schemas used simple form, such as "string", and object form, such as {"type":"string"}.

Avro's parsing canonical form treats a primitive object schema like
`{"type":"string"}` as equivalent to the simple string form. Redpanda
previously kept the object form, so equivalent schemas could be stored
under different canonical definitions.

Keep the existing sanitize traversal unchanged. After sanitization, walk
only the parts of the Avro JSON that are schemas: record field types,
array items, map values, and union branches. This leaves
primitive-looking custom metadata as-is.
@pgellert pgellert requested a review from a team May 20, 2026 18:52
@pgellert pgellert self-assigned this May 20, 2026
@pgellert pgellert requested review from a team, Copilot and nguyen-andrew and removed request for a team May 20, 2026 18:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Avro schema canonicalization in Redpanda Schema Registry by treating primitive object-form schemas (e.g. {"type":"string"}) as equivalent to the simple form ("string") when they appear at the top level and in nested schema positions, preventing false-negative schema lookups.

Changes:

  • Added a post-sanitization pass that collapses primitive object-form schemas into their simple string form, but only in Avro schema-bearing positions (record field types, array items, map values, union branches, and top-level schemas).
  • Added targeted regression tests for CORE-16246/CORE-16247, including idempotence and “do not touch metadata / logicalType / non-primitive refs” cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/v/pandaproxy/schema_registry/avro.cc Adds a schema-tree walker to collapse primitive {"type":"<primitive>"} objects into "primitive" only in schema-bearing positions, and wires it into sanitize_avro_schema_definition.
src/v/pandaproxy/schema_registry/test/sanitize_avro.cc Adds comprehensive tests covering top-level and nested primitive collapsing, equivalence between verbose/bare forms, and preservation of non-equivalent forms (logicalType, named refs, and metadata).

@vbotbuildovich
Copy link
Copy Markdown
Collaborator

CI test results

test results on build#84761
test_status test_class test_method test_arguments test_kind job_url passed reason test_history
FAIL CloudStorageUsageTest test_cloud_storage_usage_reporting_with_partition_moves null integration https://buildkite.com/redpanda/redpanda/builds/84761#019e46c6-666f-46f0-bf3e-e2d9ed2f3a72 0/1 https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=CloudStorageUsageTest&test_method=test_cloud_storage_usage_reporting_with_partition_moves
FAIL NessieCatalogSmokeTest test_nessie_with_trino {"cloud_storage_type": 1} integration https://buildkite.com/redpanda/redpanda/builds/84761#019e46c6-666f-46f0-bf3e-e2d9ed2f3a72 0/1 https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=NessieCatalogSmokeTest&test_method=test_nessie_with_trino
FAIL RestCatalogConnectionTest test_redpanda_connection_to_rest_catalog {"cloud_storage_type": 1} integration https://buildkite.com/redpanda/redpanda/builds/84761#019e46c6-666f-46f0-bf3e-e2d9ed2f3a72 0/1 https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=RestCatalogConnectionTest&test_method=test_redpanda_connection_to_rest_catalog
FAIL DeleteRecordsTest test_delete_records_concurrent_truncations {"cloud_storage_enabled": true, "truncate_point": "start_offset"} integration https://buildkite.com/redpanda/redpanda/builds/84761#019e46c6-666f-46f0-bf3e-e2d9ed2f3a72 0/1 https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=DeleteRecordsTest&test_method=test_delete_records_concurrent_truncations
FAIL EndToEndShadowIndexingTestWithDisruptions test_write_with_node_failures {"cloud_storage_type": 1} integration https://buildkite.com/redpanda/redpanda/builds/84761#019e46c6-666f-46f0-bf3e-e2d9ed2f3a72 0/1 https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=EndToEndShadowIndexingTestWithDisruptions&test_method=test_write_with_node_failures
FAIL FollowerFetchingTest test_basic_follower_fetching {"fetch_from": "fetch-from-tiered-storage"} integration https://buildkite.com/redpanda/redpanda/builds/84761#019e46c6-666f-46f0-bf3e-e2d9ed2f3a72 0/1 https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=FollowerFetchingTest&test_method=test_basic_follower_fetching
FAIL IncrementalFollowerFetchingTest test_incremental_fetch_from_follower {"follower_offline": true} integration https://buildkite.com/redpanda/redpanda/builds/84761#019e46c6-666f-46f0-bf3e-e2d9ed2f3a72 0/1 https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=IncrementalFollowerFetchingTest&test_method=test_incremental_fetch_from_follower
FAIL MultiRestartTest test_recovery_after_multiple_restarts {"cloud_storage_type": 2} integration https://buildkite.com/redpanda/redpanda/builds/84761#019e46c6-666f-46f0-bf3e-e2d9ed2f3a72 0/1 https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=MultiRestartTest&test_method=test_recovery_after_multiple_restarts
FAIL NodeWiseRecoveryTest test_node_wise_recovery {"dead_node_count": 1} integration https://buildkite.com/redpanda/redpanda/builds/84761#019e46c6-666f-46f0-bf3e-e2d9ed2f3a72 0/1 https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=NodeWiseRecoveryTest&test_method=test_node_wise_recovery
FAIL PartitionMovementTest test_move_consumer_offsets_intranode {"num_to_upgrade": 2} integration https://buildkite.com/redpanda/redpanda/builds/84761#019e46c6-666f-46f0-bf3e-e2d9ed2f3a72 0/1 https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=PartitionMovementTest&test_method=test_move_consumer_offsets_intranode
FAIL SIPartitionMovementTest test_cross_shard {"cloud_storage_type": 2, "num_to_upgrade": 0, "with_cloud_topics": false} integration https://buildkite.com/redpanda/redpanda/builds/84761#019e46c6-666f-46f0-bf3e-e2d9ed2f3a72 0/1 https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=SIPartitionMovementTest&test_method=test_cross_shard
FAIL SIPartitionMovementTest test_shadow_indexing {"cloud_storage_type": 1, "num_to_upgrade": 0, "with_cloud_topics": false} integration https://buildkite.com/redpanda/redpanda/builds/84761#019e46c6-666f-46f0-bf3e-e2d9ed2f3a72 0/1 https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=SIPartitionMovementTest&test_method=test_shadow_indexing

@pgellert pgellert enabled auto-merge May 21, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants