{"record":{"id":"70885e2541ed9fb2","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"attribute-error-in-legal-authorization-processing","errorCode":null,"errorMessage":"Attribute error in legal_authorization processing.","messagePattern":"Attribute error in legal_authorization processing\\.","errorType":"validation","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"src/resume_schemas/job_application_profile.py","lineNumber":113,"sourceCode":"            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\n        except Exception as e:\n            logger.error(f\"An unexpected error occurred while processing legal_authorization: {e}\")\n            raise RuntimeError(\"An unexpected error occurred while processing legal_authorization.\") from e\n\n        # Process work_preferences\n        try:\n            logger.debug(\"Processing work_preferences\")\n            self.work_preferences = WorkPreferences(**data['work_preferences'])\n            logger.debug(f\"Work_preferences processed: {self.work_preferences}\")\n        except KeyError as e:\n            logger.error(f\"Required field {e} is missing in work_preferences data.\")\n            raise KeyError(f\"Required field {e} is missing in work_preferences data.\") from e\n        except TypeError as e:\n            logger.error(f\"Error in work_preferences data: {e}\")\n            raise TypeError(f\"Error in work_preferences data: {e}\") from e\n        except AttributeError as e:\n            logger.error(f\"Attribute error in work_preferences processing: {e}\")\n            raise AttributeError(\"Attribute error in work_preferences processing.\") from e","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/resume_schemas/job_application_profile.py#L95-L131","documentation":"Raised when the LegalAuthorization(**...) construction (or adjacent code in that try block) raises AttributeError — typically attribute access on None/str where a dict/object was expected, e.g. .get() called on a scalar nested field. The handler re-wraps it into a generic AttributeError, losing the detail except via __cause__ and the log line.","triggerScenarios":"Nested fields inside legal_authorization being None or a string while LegalAuthorization's constructor calls dict-style methods or attribute access on them.","commonSituations":"Sparse resume data where optional legal-authorization fields are null; inconsistent producers of the resume JSON; refactors that changed nested field types.","solutions":["Check e.__cause__ / server logs for the exact attribute that failed.","Type-check nested legal_authorization fields (dict vs None vs str) before constructing the profile.","Normalize the data (fill None with {} / defaults) or make LegalInformation's constructor defensive."],"exampleFix":"# before\nla = data['legal_authorization']  # {'work_permit': None}\nself.legal_authorization = LegalAuthorization(**la)  # internal .get on None\n\n# after\nla = {k: (v if v is not None else {}) for k, v in data['legal_authorization'].items()}\nself.legal_authorization = LegalAuthorization(**la)","handlingStrategy":"validation","validationCode":"la = data.get('legal_authorization') or {}\nla = {k: (v if v is not None else {}) for k, v in la.items()}","typeGuard":"def legal_authorization_fields_valid(la) -> bool:\n    return isinstance(la, dict) and all(v is None or isinstance(v, (dict, list, str, bool, int)) for v in la.values())","tryCatchPattern":"try:\n    profile = JobApplicationProfile(**data)\nexcept AttributeError as e:\n    if 'legal_authorization' in str(e):\n        normalize_nulls(data['legal_authorization'])","preventionTips":["Normalize None-valued nested fields to {} before construction","Keep nested field types stable across data producers","Check __cause__ for the exact attribute name"],"tags":["python","attributeerror","null-handling","schema-validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}