From dab54b574cf354bf6de24dc80e4a39ab4e62a320 Mon Sep 17 00:00:00 2001 From: Mayuresh Date: Wed, 8 Apr 2026 13:15:15 +0530 Subject: [PATCH] Revert "fix(schemav2validator): conditionally strip @context/@type based on schema properties" The fix in the previous PR is no longer required because the protocol is changed to solve the root cause, reverting this change. --- .../schemav2validator/extended_schema.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/pkg/plugin/implementation/schemav2validator/extended_schema.go b/pkg/plugin/implementation/schemav2validator/extended_schema.go index f5f8747..92c5ed0 100644 --- a/pkg/plugin/implementation/schemav2validator/extended_schema.go +++ b/pkg/plugin/implementation/schemav2validator/extended_schema.go @@ -383,22 +383,12 @@ func (c *schemaCache) validateReferencedObject( return fmt.Errorf("at %s: %w", obj.Path, err) } - // Strip @context and @type only if the schema does not declare them as properties. - // Some schemas explicitly require these fields; stripping them in that case - // would cause a "missing required field" validation error. - schemaProps := schema.Value.Properties - _, contextInSchema := schemaProps["@context"] - _, typeInSchema := schemaProps["@type"] - - domainData := make(map[string]interface{}, len(obj.Data)) + // Strip JSON-LD metadata before validation + domainData := make(map[string]interface{}, len(obj.Data)-2) for k, v := range obj.Data { - if k == "@context" && !contextInSchema { - continue + if k != "@context" && k != "@type" { + domainData[k] = v } - if k == "@type" && !typeInSchema { - continue - } - domainData[k] = v } // Validate domain-specific data against schema