{"record":{"id":"aacf445d0c7b5646","repo":"feder-cr/Jobs_Applier_AI_Agent_AIHawk","slug":"error-in-legal-authorization-data-e","errorCode":null,"errorMessage":"Error in legal_authorization data: {e}","messagePattern":"Error in legal_authorization data: (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/resume_schemas/job_application_profile.py","lineNumber":110,"sourceCode":"            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\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","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/feder-cr/Jobs_Applier_AI_Agent_AIHawk/blob/79155b52faccfbd19b834680af285eac70dd2df4/src/resume_schemas/job_application_profile.py#L92-L128","documentation":"TypeError raised from the legal_authorization block in JobApplicationProfile.__init__. Two typical sources: data['legal_authorization'] is not a mapping so **-unpacking fails with 'argument of type ... is not a mapping', or LegalAuthorization's constructor received an unexpected/positional argument ('__init__() got an unexpected keyword argument ...'). The original message is included via {e}.","triggerScenarios":"legal_authorization given as a string/list/None in the resume data; extra keys in the legal_authorization dict that LegalAuthorization.__init__ does not accept; wrong positional layout when constructing programmatically.","commonSituations":"YAML where legal_authorization: is a scalar or list; schema drift after adding/removing fields from LegalAuthorization; LLM- or template-generated resumes with extra keys like 'notes'.","solutions":["Ensure data['legal_authorization'] is a dict; coerce or default it before construction.","Remove or filter unknown keys: pass only the fields LegalAuthorization accepts.","Align the data schema with the current LegalAuthorization constructor signature (version check)."],"exampleFix":"# before\nself.legal_authorization = LegalAuthorization(**data['legal_authorization'])  # value is a str\n\n# after\nla = data.get('legal_authorization') or {}\nif not isinstance(la, dict):\n    raise TypeError('legal_authorization must be a dict')\nself.legal_authorization = LegalAuthorization(**la)","handlingStrategy":"type-guard","validationCode":"la = data.get('legal_authorization')\nif not isinstance(la, dict):\n    raise TypeError('legal_authorization must be a dict')","typeGuard":"def is_legal_authorization_dict(data: dict) -> bool:\n    return isinstance(data.get('legal_authorization'), dict)","tryCatchPattern":"try:\n    profile = JobApplicationProfile(**data)\nexcept TypeError as e:\n    if 'legal_authorization' in str(e):\n        fix_and_retry(data)  # coerce section to dict","preventionTips":["Never let scalar values stand in for object sections in YAML","Filter unknown keys before **-unpacking","Add schema validation (pydantic/jsonschema) at ingest"],"tags":["python","typeerror","schema-validation","dict-unpacking"],"backgroundTag":"schema-validation-failed","analyzedSha":"79155b52faccfbd19b834680af285eac70dd2df4","analyzedAt":"2026-08-28T14:10:26.659Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}