{"record":{"id":"3d5d50ae3a4479b4","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"unexpected-error-while-parsing-yaml-e","errorCode":null,"errorMessage":"Unexpected error while parsing YAML: {e}","messagePattern":"Unexpected error while parsing YAML: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/resume_schemas/resume.py","lineNumber":122,"sourceCode":"            return [{k: v} for k, v in exam.items()]\n        return exam\n\n    def __init__(self, yaml_str: str):\n        try:\n            # Parse the YAML string\n            data = yaml.safe_load(yaml_str)\n\n            if 'education_details' in data:\n                for ed in data['education_details']:\n                    if 'exam' in ed:\n                        ed['exam'] = self.normalize_exam_format(ed['exam'])\n\n            # Create an instance of Resume from the parsed data\n            super().__init__(**data)\n        except yaml.YAMLError as e:\n            raise ValueError(\"Error parsing YAML file.\") from e\n        except Exception as e:\n            raise Exception(f\"Unexpected error while parsing YAML: {e}\") from e\n\n\n    def _process_personal_information(self, data: Dict[str, Any]) -> PersonalInformation:\n        try:\n            return PersonalInformation(**data)\n        except TypeError as e:\n            raise TypeError(f\"Invalid data for PersonalInformation: {e}\") from e\n        except AttributeError as e:\n            raise AttributeError(f\"AttributeError in PersonalInformation: {e}\") from e\n        except Exception as e:\n            raise Exception(f\"Unexpected error in PersonalInformation processing: {e}\") from e\n\n    def _process_education_details(self, data: List[Dict[str, Any]]) -> List[EducationDetails]:\n        education_list = []\n        for edu in data:\n            try:\n                exams = [Exam(name=k, grade=v) for k, v in edu.get('exam', {}).items()]\n                education = EducationDetails(","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/resume_schemas/resume.py#L104-L140","documentation":"Bare-Exception catch-all from Resume.__init__'s parsing block: any failure that is not a yaml.YAMLError — including errors in exam normalization, PersonalInformation/section construction, or super().__init__(**data) — is re-raised as Exception('Unexpected error while parsing YAML: {e}'). The message interpolates the original error text, and the original is chained, so the YAML is often innocent; the real fault is usually in downstream model construction.","triggerScenarios":"Parsed data passes YAML checks but fails schema construction: missing required keys, wrong types in sections, super().__init__ (JobApplicationProfile) raising KeyError/TypeError, or normalize_exam_format receiving an unexpected structure.","commonSituations":"Valid YAML that doesn't match the resume schema (renamed sections, null sections); schema version drift between resume files and library; nested 'exam' fields in education with unexpected shapes hitting normalize_exam_format.","solutions":["Read the interpolated {e} / __cause__ — it names the actual failure (often one of the JobApplicationProfile section errors).","Validate the parsed structure against the expected schema: required top-level keys, dict-valued sections.","Fix the offending section in the YAML, or default/normalize it before constructing Resume.","Narrow this handler to specific exception types once the recurring cause is known."],"exampleFix":"# before\ntry:\n    resume = Resume('resume.yaml')\nexcept Exception as e:\n    pass  # opaque\n\n# after\ntry:\n    resume = Resume('resume.yaml')\nexcept ValueError:\n    raise  # genuine YAML syntax problem\nexcept Exception as e:\n    logging.error(\"resume schema issue: %r (cause=%r)\", e, e.__cause__)\n    raise","handlingStrategy":"try-catch","validationCode":"import yaml\nwith open(path) as f:\n    data = yaml.safe_load(f)\nrequired = ['personal_information', 'education', 'work_experience']\nassert isinstance(data, dict) and all(k in data for k in required)","typeGuard":"def looks_like_resume_data(data) -> bool:\n    return isinstance(data, dict) and all(\n        isinstance(data.get(k), (dict, list)) or data.get(k) is None\n        for k in ('personal_information', 'self_identification', 'education')\n    )","tryCatchPattern":"try:\n    resume = Resume(path)\nexcept ValueError:\n    raise  # YAML syntax issue\nexcept Exception as e:\n    log.error('schema failure: %r cause=%r', e, e.__cause__)","preventionTips":["Validate the parsed structure (keys, section types) before constructing Resume","Default missing sections to {} instead of letting the constructor fail","Pin library version and regenerate resume fixtures on upgrade","Preserve chained exceptions for debugging"],"tags":["python","yaml","schema-validation","resume"],"backgroundTag":"schema-validation-failed","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}