{"record":{"id":"a96ccfa9ca074853","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"attribute-error-in-self-identification-processing","errorCode":null,"errorMessage":"Attribute error in self_identification processing.","messagePattern":"Attribute error in self_identification processing\\.","errorType":"validation","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"src/resume_schemas/job_application_profile.py","lineNumber":95,"sourceCode":"\n        if not isinstance(data, dict):\n            logger.error(f\"YAML data must be a dictionary, received: {type(data)}\")\n            raise TypeError(\"YAML data must be a dictionary.\")\n\n        # Process self_identification\n        try:\n            logger.debug(\"Processing self_identification\")\n            self.self_identification = SelfIdentification(**data['self_identification'])\n            logger.debug(f\"self_identification processed: {self.self_identification}\")\n        except KeyError as e:\n            logger.error(f\"Required field {e} is missing in self_identification data.\")\n            raise KeyError(f\"Required field {e} is missing in self_identification data.\") from e\n        except TypeError as e:\n            logger.error(f\"Error in self_identification data: {e}\")\n            raise TypeError(f\"Error in self_identification data: {e}\") from e\n        except AttributeError as e:\n            logger.error(f\"Attribute error in self_identification processing: {e}\")\n            raise AttributeError(\"Attribute error in self_identification processing.\") from e\n        except Exception as e:\n            logger.error(f\"An unexpected error occurred while processing self_identification: {e}\")\n            raise RuntimeError(\"An unexpected error occurred while processing self_identification.\") from e\n\n        # Process legal_authorization\n        try:\n            logger.debug(\"Processing legal_authorization\")\n            self.legal_authorization = LegalAuthorization(**data['legal_authorization'])\n            logger.debug(f\"legal_authorization processed: {self.legal_authorization}\")\n        except KeyError as e:\n            logger.error(f\"Required field {e} is missing in legal_authorization data.\")\n            raise KeyError(f\"Required field {e} is missing in legal_authorization data.\") from e\n        except TypeError as e:\n            logger.error(f\"Error in legal_authorization data: {e}\")\n            raise TypeError(f\"Error in legal_authorization data: {e}\") from e\n        except AttributeError as e:\n            logger.error(f\"Attribute error in legal_authorization processing: {e}\")\n            raise AttributeError(\"Attribute error in legal_authorization processing.\") from e","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/resume_schemas/job_application_profile.py#L77-L113","documentation":"Raised while constructing JobApplicationProfile when processing the self_identification section raises AttributeError (e.g. calling a method/attribute on None or a non-dict value). The constructor unpacks data['self_identification'] into SelfIdentification(**...) and converts any AttributeError into this opaque re-raise, chaining the original as __cause__. The real cause is in the logged message and the chained exception, not the message text.","triggerScenarios":"Passing resume data where data['self_identification'] (or a nested field) is None/str instead of dict, so attribute access inside SelfIdentification's own __init__ (e.g. x.get, list ops) fails with AttributeError, which this handler re-wraps.","commonSituations":"YAML/JSON resume files where self_identification is null, empty string, or malformed; LLM-generated resume JSON with wrong types; upstream keys present but with scalar values where objects are expected.","solutions":["Inspect the chained exception (e.__cause__) and the logger.error line to see the exact attribute that failed.","Validate that data['self_identification'] is a dict and each nested field matches SelfIdentification's expected types before constructing the profile.","Fix the source data (e.g. replace null self_identification with {}) or make nested constructors defensive with (value or {}).","If nulls are legitimate, gate construction: only build the section when the key holds a mapping."],"exampleFix":"# before\nprofile = JobApplicationProfile(**data)  # data['self_identification'] is None -> AttributeError\n\n# after\nif not isinstance(data.get('self_identification'), dict):\n    data['self_identification'] = {}\nprofile = JobApplicationProfile(**data)","handlingStrategy":"validation","validationCode":"si = data.get('self_identification')\nassert si is None or isinstance(si, dict), 'self_identification must be a dict'","typeGuard":"def has_valid_self_identification(data: dict) -> bool:\n    si = data.get('self_identification')\n    return si is None or isinstance(si, dict)","tryCatchPattern":"try:\n    profile = JobApplicationProfile(**data)\nexcept AttributeError as e:\n    log.error(\"self_identification attr failure: %r cause=%r\", e, e.__cause__)","preventionTips":["Type-check each profile section is a dict before constructing JobApplicationProfile","Replace null sections with {} upstream","Log e.__cause__, not just str(e), when triaging"],"tags":["python","dataclass","schema-validation","constructor"],"backgroundTag":"schema-validation-failed","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}