feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · ValueError
Error parsing YAML file.
Error message
Error parsing YAML file.
What it means
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.
Source
Thrown at src/resume_schemas/resume.py:120
def normalize_exam_format(exam):
if isinstance(exam, dict):
return [{k: v} for k, v in exam.items()]
return exam
def __init__(self, yaml_str: str):
try:
# Parse the YAML string
data = yaml.safe_load(yaml_str)
if 'education_details' in data:
for ed in data['education_details']:
if 'exam' in ed:
ed['exam'] = self.normalize_exam_format(ed['exam'])
# Create an instance of Resume from the parsed data
super().__init__(**data)
except yaml.YAMLError as e:
raise ValueError("Error parsing YAML file.") from e
except Exception as e:
raise Exception(f"Unexpected error while parsing YAML: {e}") from e
def _process_personal_information(self, data: Dict[str, Any]) -> PersonalInformation:
try:
return PersonalInformation(**data)
except TypeError as e:
raise TypeError(f"Invalid data for PersonalInformation: {e}") from e
except AttributeError as e:
raise AttributeError(f"AttributeError in PersonalInformation: {e}") from e
except Exception as e:
raise Exception(f"Unexpected error in PersonalInformation processing: {e}") from e
def _process_education_details(self, data: List[Dict[str, Any]]) -> List[EducationDetails]:
education_list = []
for edu in data:
try:View on GitHub (pinned to 79155b52fa)
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).
Example fix
# before
resume = Resume('resume.yaml') # raises ValueError: Error parsing YAML file.
# after
import yaml
try:
resume = Resume('resume.yaml')
except ValueError as e:
if isinstance(e.__cause__, yaml.YAMLError):
print(f"YAML syntax error: {e.__cause__}") # includes line/column
raise Defensive patterns
Strategy: validation
Validate before calling
import yaml
with open(path) as f:
yaml.safe_load(f) # dry-run parse; raises YAMLError with line/col before Resume() Try / catch
import yaml
try:
resume = Resume(path)
except ValueError as e:
if isinstance(e.__cause__, yaml.YAMLError):
show_yaml_error(e.__cause__) # has problem_mark line/column
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Error parsing YAML file.
- Unexpected error while parsing YAML: {e}
- Could not extract section name from the response.
- You must choose a style before generating the PDF.
- Il file di stile non è stato trovato nel percorso: {style_pa
AI-assisted analysis of feder-cr/Jobs_Applier_AI_Agent_AIHawk@79155b52fa (2026-08-28).
Data as JSON: /api/errors/2eabd390bebc0a9b.
Report an issue: GitHub.