{"record":{"id":"2eabd390bebc0a9b","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"error-parsing-yaml-file-2eabd3","errorCode":null,"errorMessage":"Error parsing YAML file.","messagePattern":"Error parsing YAML file\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/resume_schemas/resume.py","lineNumber":120,"sourceCode":"    def normalize_exam_format(exam):\n        if isinstance(exam, dict):\n            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:","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/resume_schemas/resume.py#L102-L138","documentation":"Raised by Resume.__init__ when yaml.safe_load (or subsequent pre-processing and super().__init__) raises yaml.YAMLError — i.e. the resume file's YAML text is syntactically invalid. The ValueError replaces the parser error, with the PyYAML exception (including line/column markers) attached as __cause__. Note the try block also covers exam-format normalization and the parent constructor, so a YAMLError raised anywhere in it lands here.","triggerScenarios":"Loading a resume file with bad YAML: tabs used for indentation, unclosed quotes/brackets, duplicate keys (with strict loaders), colons missing after keys, or an empty file that later code paths treat as None.","commonSituations":"Hand-edited resume YAML breaking indentation; files with Windows line endings/encoding issues; YAML with date-like strings parsed into objects the constructor can't consume; truncated files from failed downloads or LLM output.","solutions":["Open the chained yaml.YAMLError (__cause__) — PyYAML reports the exact line and column of the syntax error.","Paste the file into a YAML linter (yamllint file.yaml) and fix flagged indentation/quoting issues.","Quote scalar values containing colons or special characters; replace tabs with spaces.","If the file may be empty or non-YAML, check content before calling Resume(file_path)."],"exampleFix":"# before\nresume = Resume('resume.yaml')  # raises ValueError: Error parsing YAML file.\n\n# after\nimport yaml\ntry:\n    resume = Resume('resume.yaml')\nexcept ValueError as e:\n    if isinstance(e.__cause__, yaml.YAMLError):\n        print(f\"YAML syntax error: {e.__cause__}\")  # includes line/column\n    raise","handlingStrategy":"validation","validationCode":"import yaml\nwith open(path) as f:\n    yaml.safe_load(f)  # dry-run parse; raises YAMLError with line/col before Resume()","typeGuard":null,"tryCatchPattern":"import yaml\ntry:\n    resume = Resume(path)\nexcept ValueError as e:\n    if isinstance(e.__cause__, yaml.YAMLError):\n        show_yaml_error(e.__cause__)  # has problem_mark line/column\n    raise","preventionTips":["Run yamllint on resume files in CI","Quote strings containing colons or special chars","Use spaces, never tabs, for YAML indentation","Check files are non-empty and UTF-8 before loading"],"tags":["python","yaml","parsing","resume"],"backgroundTag":"yaml-parse-error","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}