{"record":{"id":"71ea277bf5a03b35","repo":"microsoft/VibeVoice","slug":"no-valid-entries-found-in-json-file","errorCode":null,"errorMessage":"No valid entries found in JSON file","messagePattern":"No valid entries found in JSON file","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"vibevoice/processor/vibevoice_processor.py","lineNumber":554,"sourceCode":"            \n            if speaker is None or text is None:\n                logger.warning(f\"Skipping entry missing speaker or text: {item}\")\n                continue\n            \n            # Ensure speaker ID is valid\n            try:\n                speaker_id = int(speaker)\n            except (ValueError, TypeError):\n                logger.warning(f\"Invalid speaker ID: {speaker}, skipping entry\")\n                continue\n            \n            # Clean up text\n            text = text.strip()\n            if text:\n                script_lines.append(f\"Speaker {speaker_id}: {text}\")\n        \n        if not script_lines:\n            raise ValueError(\"No valid entries found in JSON file\")\n            \n        return \"\\n\".join(script_lines)\n\n    def _convert_text_to_script(self, text_file: str) -> str:\n        \"\"\"\n        Convert text file to script format.\n        Handles multiple formats:\n        1. Already formatted as \"Speaker X: text\"\n        2. Plain text (assigns to Speaker 1)\n        \n        Handles edge cases like multiple colons in a line.\n        \"\"\"\n        with open(text_file, 'r', encoding='utf-8') as f:\n            lines = f.readlines()\n        \n        script_lines = []\n        current_speaker = 1\n        ","sourceCodeStart":536,"sourceCodeEnd":572,"githubUrl":"https://github.com/microsoft/VibeVoice/blob/94da20d98b2fa7688e9cbfaf7692ddb4954f7600/vibevoice/processor/vibevoice_processor.py#L536-L572","documentation":"After the JSON file passes the 'is a list' check, each entry is validated: non-dicts are skipped with a warning, entries missing 'speaker' or 'text' are skipped, non-integer speaker ids are skipped, and empty/whitespace-only text is dropped. If every entry is filtered out, script_lines is empty and this ValueError fires. The earlier warnings in the log tell you which filter killed the entries.","triggerScenarios":"A JSON list where all entries have speaker ids like 'speaker_1' or 'one' (int() fails), or all texts are empty strings, or all entries use different keys ('spk'/'utterance' instead of 'speaker'/'text').","commonSituations":"Schema drift: annotation tools renaming fields; speaker names instead of numeric ids ('narrator'); transcripts where text is stored under 'transcript' rather than 'text'.","solutions":["Check the logger.warning lines emitted just before the exception — they name each skipped entry and why.","Ensure every entry is a dict with 'speaker' as an integer-parseable value and a non-empty 'text'.","Rename mismatched keys (spk->speaker, transcript->text) with a small jq/python pass before calling the processor."],"exampleFix":"# before\n[{\"spk\": \"1\", \"transcript\": \"Hi\"}]\n\n# after\n[{\"speaker\": \"1\", \"text\": \"Hi\"}]","handlingStrategy":"validation","validationCode":"import json\ndata = json.load(open(path))\nvalid = [{'speaker': int(e['speaker']), 'text': e['text'].strip()}\n         for e in data\n         if isinstance(e, dict) and e.get('speaker') and e.get('text', '').strip()\n         and str(e['speaker']).isdigit()]\nif not valid:\n    raise ValueError('transcript has no usable entries — check speaker/text keys')","typeGuard":"def is_valid_entry(e) -> bool:\n    return (isinstance(e, dict) and str(e.get('speaker', '')).isdigit()\n            and bool(str(e.get('text', '')).strip()))","tryCatchPattern":"try:\n    enc = processor(text=json_path)\nexcept ValueError as e:\n    if 'No valid entries' in str(e):\n        logger.error('transcript schema mismatch; expected speaker:int + text:str entries')\n        raise\n    raise","preventionTips":["Pre-validate entries with the same rules (int speaker, non-empty text) before the call.","Enable logging to see per-entry skip warnings that precede the exception.","Pin the transcript schema in your data contracts to avoid key renames."],"tags":["json","script","validation","data-quality"],"backgroundTag":null,"analyzedSha":"94da20d98b2fa7688e9cbfaf7692ddb4954f7600","analyzedAt":"2026-08-15T04:12:07.418Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}