{"record":{"id":"93e744fb532e59e6","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"invalid-data-for-personalinformation-e","errorCode":null,"errorMessage":"Invalid data for PersonalInformation: {e}","messagePattern":"Invalid data for PersonalInformation: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/resume_schemas/resume.py","lineNumber":129,"sourceCode":"\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(\n                    education_level=edu.get('education_level'),\n                    institution=edu.get('institution'),\n                    field_of_study=edu.get('field_of_study'),\n                    final_evaluation_grade=edu.get('final_evaluation_grade'),\n                    start_date=edu.get('start_date'),\n                    year_of_completion=edu.get('year_of_completion'),\n                    exam=exams","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/resume_schemas/resume.py#L111-L147","documentation":"Raised when constructing the PersonalInformation dataclass with keyword arguments that don't match its __init__ signature — e.g. unexpected keys, missing required fields, or wrong types. Python's dataclass __init__ (or a validating __post_init__) raises TypeError, which this wrapper re-raises with a descriptive prefix. It almost always means the input dict (often parsed JSON) doesn't conform to the resume schema.","triggerScenarios":"Calling the resume parser/constructor with a dict containing keys that are not fields of PersonalInformation, omitting required fields (no defaults), or passing a non-mapping. Typical entry point: _process_personal_information({'name': ..., 'extra_key': ...}).","commonSituations":"Upstream LLM/JSON extraction produced extra or renamed keys; schema drift after adding/removing dataclass fields; a None passed instead of a dict; version change of the resume schema.","solutions":["Inspect the full TypeError message ({e}) — it names the exact unexpected/missing argument; fix the input dict accordingly.","If extra keys are legitimate, add them as fields to PersonalInformation or filter data through {k: v for k, v in data.items() if k in expected_fields} before construction.","Give the offending fields default values (field: Optional[str] = None) so partial data no longer raises.","Validate the payload with a schema (pydantic/jsonschema) before calling _process_personal_information."],"exampleFix":"// before\npi = PersonalInformation(**data)  # data has extra/missing keys\n\n# after\nallowed = {f.name for f in dataclasses.fields(PersonalInformation)}\npi = PersonalInformation(**{k: v for k, v in data.items() if k in allowed})","handlingStrategy":"validation","validationCode":"import dataclasses\nALLOWED_PI = {f.name for f in dataclasses.fields(PersonalInformation)}\nREQUIRED_PI = {f.name for f in dataclasses.fields(PersonalInformation) if f.default is dataclasses.MISSING and f.default_factory is dataclasses.MISSING}\n\ndef validate_personal_information(data):\n    if not isinstance(data, dict):\n        raise ValueError(f\"expected dict, got {type(data).__name__}\")\n    missing = REQUIRED_PI - data.keys()\n    if missing:\n        raise ValueError(f\"missing required fields: {sorted(missing)}\")\n    extra = set(data) - ALLOWED_PI\n    if extra:\n        raise ValueError(f\"unexpected fields: {sorted(extra)}\")\n    return {k: v for k, v in data.items() if k in ALLOWED_PI}","typeGuard":"from typing import Dict, Any, TypeGuard\n\ndef is_personal_information_payload(data: Any) -> TypeGuard[Dict[str, Any]]:\n    return isinstance(data, dict) and all(isinstance(k, str) for k in data)","tryCatchPattern":"try:\n    pi = _process_personal_information(data)\nexcept TypeError as e:\n    logger.error(\"personal information schema mismatch: %s\", e)\n    # fall back to defaults or skip section\n    pi = PersonalInformation()  # only if all fields have defaults\nexcept AttributeError as e:\n    logger.error(\"personal information payload malformed: %s\", e)\n    raise","preventionTips":["Filter incoming dict keys against dataclasses.fields(...) before ** construction","Give dataclass fields Optional[...] = None defaults for non-critical data","Keep the schema and the extractor prompt in sync; re-run extraction tests after schema changes"],"tags":["dataclass","typeerror","schema-validation","python"],"backgroundTag":"dataclass-construction-typeerror","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}