feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · AttributeError
AttributeError in PersonalInformation: {e}
Error message
AttributeError in PersonalInformation: {e} What it means
The wrapper around PersonalInformation(**data) caught an AttributeError — the input dict (or a nested value) is missing an attribute the construction path expects. This typically happens when `data` is not actually a dict (e.g. a string or None) and code tries attribute-style access, or a __post_init__ validator accesses self.<field> on a misconfigured dataclass.
Source
Thrown at src/resume_schemas/resume.py:131
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(
education_level=edu.get('education_level'),
institution=edu.get('institution'),
field_of_study=edu.get('field_of_study'),
final_evaluation_grade=edu.get('final_evaluation_grade'),
start_date=edu.get('start_date'),
year_of_completion=edu.get('year_of_completion'),
exam=exams
)
education_list.append(education)View on GitHub (pinned to 79155b52fa)
Solutions
- Check the chained original exception (`from e`) to see which attribute was missing.
- Guard at the top: if not isinstance(data, dict): raise a clear ValueError with the received type.
- Fix or remove the stale attribute reference in __post_init__ or the dataclass.
- Ensure the upstream parser actually yields a dict for personal_information.
Example fix
// before
_process_personal_information(json.loads(text)) # text may decode to a string
# after
data = json.loads(text)
if not isinstance(data, dict):
raise ValueError(f"expected object for personal_information, got {type(data).__name__}")
_process_personal_information(data) Defensive patterns
Strategy: type-guard
Validate before calling
if not isinstance(data, dict):
raise ValueError(f"personal_information must be a dict, got {type(data).__name__}") Type guard
def is_dict_payload(x: Any) -> TypeGuard[dict]:
return isinstance(x, dict) Try / catch
try:
pi = _process_personal_information(data)
except AttributeError as e:
if 'object has no attribute' in str(e):
logger.error("payload is not a dict: %s", e.__cause__ or e)
raise Prevention
- Validate json.loads output type before passing downstream
- Never assume extraction output is an object; check type first
- Log the offending payload type on failure
When it happens
Trigger: Passing a non-dict (string, None, object) as `data` so that internal handling raises AttributeError; a __post_init__ referencing an attribute deleted/renamed in the dataclass definition.
Common situations: JSON parse returned a scalar/None instead of an object; refactoring the dataclass removed a field still referenced elsewhere; nested structures assumed to be objects but are strings.
Related errors
- Attribute error in self_identification processing.
- Attribute error in legal_authorization processing.
- Invalid data for PersonalInformation: {e}
- Missing field in education details: {e}
- AttributeError in Education: {e}
AI-assisted analysis of feder-cr/Jobs_Applier_AI_Agent_AIHawk@79155b52fa (2026-08-28).
Data as JSON: /api/errors/812e0fee85dac73d.
Report an issue: GitHub.