From aa52727a1e1e52e0cf5a651d85d6bae7644e8128 Mon Sep 17 00:00:00 2001 From: johndoe6345789 Date: Mon, 9 Mar 2026 23:11:44 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20update=20gate=201.1=20to=20validate=20JS?= =?UTF-8?q?ON=20entity=20schemas=20(YAML=E2=86=92JSON=20migration)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Switch from PyYAML to stdlib json (no pip install needed) - entities.yaml → entities.json registry - *.yaml glob → *.json glob - Handle array-format files (forum, irc, media, streaming) - 42 entities across 35 files now pass Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/gated-pipeline.yml | 55 +++++++++++++--------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/.github/workflows/gated-pipeline.yml b/.github/workflows/gated-pipeline.yml index 3933eaf39..28273468c 100644 --- a/.github/workflows/gated-pipeline.yml +++ b/.github/workflows/gated-pipeline.yml @@ -308,67 +308,62 @@ jobs: with: python-version: '3.11' - - name: Install PyYAML - run: pip install pyyaml - - - name: Validate DBAL entity YAML schemas + - name: Validate DBAL entity JSON schemas run: | python3 -c " - import yaml, sys, os, glob + import json, sys, os, glob schema_dir = 'dbal/shared/api/schema/entities' errors = [] total_entities = 0 - # 1. Validate entities.yaml registry exists and refs resolve - registry = os.path.join(schema_dir, 'entities.yaml') + # 1. Validate entities.json registry exists and refs resolve + registry = os.path.join(schema_dir, 'entities.json') if not os.path.exists(registry): - errors.append('Missing entities.yaml registry') + errors.append('Missing entities.json registry') else: with open(registry) as f: - reg = yaml.safe_load(f) + reg = json.load(f) refs = [e['\$ref'] for e in reg.get('entities', [])] for ref in refs: - path = os.path.join(schema_dir, ref) + path = os.path.join(schema_dir, ref.lstrip('./')) if not os.path.exists(path): errors.append(f'Registry ref not found: {ref}') - # 2. Validate each entity YAML (supports multi-doc files) - yamls = glob.glob(os.path.join(schema_dir, '**/*.yaml'), recursive=True) - entity_files = [f for f in yamls if os.path.basename(f) != 'entities.yaml'] + # 2. Validate each entity JSON file + jsons = glob.glob(os.path.join(schema_dir, '**/*.json'), recursive=True) + entity_files = [f for f in jsons if os.path.basename(f) != 'entities.json'] - def validate_doc(doc, rel, idx=''): - label = f'{rel}{idx}' + def validate_doc(doc, rel): if not doc or not isinstance(doc, dict): - errors.append(f'{label}: empty or non-mapping document') + errors.append(f'{rel}: empty or non-mapping document') return - # Entity name can be 'entity', 'name', or 'displayName' has_name = any(k in doc for k in ('entity', 'name', 'displayName')) if not has_name: - errors.append(f'{label}: missing entity/name/displayName key') + errors.append(f'{rel}: missing entity/name/displayName key') if 'fields' not in doc: - errors.append(f'{label}: missing fields key') + errors.append(f'{rel}: missing fields key') elif not isinstance(doc['fields'], dict): - errors.append(f'{label}: fields must be a mapping') + errors.append(f'{rel}: fields must be a mapping') else: for fname, fdef in doc['fields'].items(): if not isinstance(fdef, dict) or 'type' not in fdef: - errors.append(f'{label}: field {fname} missing type') + errors.append(f'{rel}: field {fname} missing type') for filepath in sorted(entity_files): rel = os.path.relpath(filepath, schema_dir) try: with open(filepath) as f: - docs = list(yaml.safe_load_all(f)) - if len(docs) == 1: - validate_doc(docs[0], rel) - total_entities += 1 - else: - for i, doc in enumerate(docs): - validate_doc(doc, rel, f'[{i}]') + doc = json.load(f) + if isinstance(doc, list): + for i, item in enumerate(doc): + validate_doc(item, f'{rel}[{i}]') total_entities += 1 - except yaml.YAMLError as e: - errors.append(f'{rel}: YAML parse error: {e}') + else: + validate_doc(doc, rel) + total_entities += 1 + except json.JSONDecodeError as e: + errors.append(f'{rel}: JSON parse error: {e}') print(f'Checked {len(entity_files)} files, {total_entities} entities') if errors: