feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · Exception

Unexpected error while parsing YAML: {e}

Error message

Unexpected error while parsing YAML: {e}

What it means

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.

Source

Thrown at src/resume_schemas/resume.py:122

            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:
                exams = [Exam(name=k, grade=v) for k, v in edu.get('exam', {}).items()]
                education = EducationDetails(

View on GitHub (pinned to 79155b52fa)

Solutions

  1. Read the interpolated {e} / __cause__ — it names the actual failure (often one of the JobApplicationProfile section errors).
  2. Validate the parsed structure against the expected schema: required top-level keys, dict-valued sections.
  3. Fix the offending section in the YAML, or default/normalize it before constructing Resume.
  4. Narrow this handler to specific exception types once the recurring cause is known.

Example fix

# before
try:
    resume = Resume('resume.yaml')
except Exception as e:
    pass  # opaque

# after
try:
    resume = Resume('resume.yaml')
except ValueError:
    raise  # genuine YAML syntax problem
except Exception as e:
    logging.error("resume schema issue: %r (cause=%r)", e, e.__cause__)
    raise
Defensive patterns

Strategy: try-catch

Validate before calling

import yaml
with open(path) as f:
    data = yaml.safe_load(f)
required = ['personal_information', 'education', 'work_experience']
assert isinstance(data, dict) and all(k in data for k in required)

Type guard

def looks_like_resume_data(data) -> bool:
    return isinstance(data, dict) and all(
        isinstance(data.get(k), (dict, list)) or data.get(k) is None
        for k in ('personal_information', 'self_identification', 'education')
    )

Try / catch

try:
    resume = Resume(path)
except ValueError:
    raise  # YAML syntax issue
except Exception as e:
    log.error('schema failure: %r cause=%r', e, e.__cause__)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of feder-cr/Jobs_Applier_AI_Agent_AIHawk@79155b52fa (2026-08-28). Data as JSON: /api/errors/3d5d50ae3a4479b4. Report an issue: GitHub.