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

  1. Open the chained yaml.YAMLError (__cause__) — PyYAML reports the exact line and column of the syntax error.
  2. Paste the file into a YAML linter (yamllint file.yaml) and fix flagged indentation/quoting issues.
  3. Quote scalar values containing colons or special characters; replace tabs with spaces.
  4. 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

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


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.