feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · TypeError
Error in legal_authorization data: {e}
Error message
Error in legal_authorization data: {e} What it means
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}.
Source
Thrown at src/resume_schemas/job_application_profile.py:110
raise TypeError(f"Error in self_identification data: {e}") from e
except AttributeError as e:
logger.error(f"Attribute error in self_identification processing: {e}")
raise AttributeError("Attribute error in self_identification processing.") from e
except Exception as e:
logger.error(f"An unexpected error occurred while processing self_identification: {e}")
raise RuntimeError("An unexpected error occurred while processing self_identification.") from e
# Process legal_authorization
try:
logger.debug("Processing legal_authorization")
self.legal_authorization = LegalAuthorization(**data['legal_authorization'])
logger.debug(f"legal_authorization processed: {self.legal_authorization}")
except KeyError as e:
logger.error(f"Required field {e} is missing in legal_authorization data.")
raise KeyError(f"Required field {e} is missing in legal_authorization data.") from e
except TypeError as e:
logger.error(f"Error in legal_authorization data: {e}")
raise TypeError(f"Error in legal_authorization data: {e}") from e
except AttributeError as e:
logger.error(f"Attribute error in legal_authorization processing: {e}")
raise AttributeError("Attribute error in legal_authorization processing.") from e
except Exception as e:
logger.error(f"An unexpected error occurred while processing legal_authorization: {e}")
raise RuntimeError("An unexpected error occurred while processing legal_authorization.") from e
# Process work_preferences
try:
logger.debug("Processing work_preferences")
self.work_preferences = WorkPreferences(**data['work_preferences'])
logger.debug(f"Work_preferences processed: {self.work_preferences}")
except KeyError as e:
logger.error(f"Required field {e} is missing in work_preferences data.")
raise KeyError(f"Required field {e} is missing in work_preferences data.") from e
except TypeError as e:
logger.error(f"Error in work_preferences data: {e}")
raise TypeError(f"Error in work_preferences data: {e}") from eView on GitHub (pinned to 79155b52fa)
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).
Example fix
# before
self.legal_authorization = LegalAuthorization(**data['legal_authorization']) # value is a str
# after
la = data.get('legal_authorization') or {}
if not isinstance(la, dict):
raise TypeError('legal_authorization must be a dict')
self.legal_authorization = LegalAuthorization(**la) Defensive patterns
Strategy: type-guard
Validate before calling
la = data.get('legal_authorization')
if not isinstance(la, dict):
raise TypeError('legal_authorization must be a dict') Type guard
def is_legal_authorization_dict(data: dict) -> bool:
return isinstance(data.get('legal_authorization'), dict) Try / catch
try:
profile = JobApplicationProfile(**data)
except TypeError as e:
if 'legal_authorization' in str(e):
fix_and_retry(data) # coerce section to dict Prevention
- Never let scalar values stand in for object sections in YAML
- Filter unknown keys before **-unpacking
- Add schema validation (pydantic/jsonschema) at ingest
When it happens
Trigger: 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.
Common situations: 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'.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Error in work_preferences data: {e}
- Error in availability data: {e}
- Error in salary_expectations data: {e}
- Invalid data for PersonalInformation: {e}
- Attribute error in self_identification processing.
AI-assisted analysis of feder-cr/Jobs_Applier_AI_Agent_AIHawk@79155b52fa (2026-08-28).
Data as JSON: /api/errors/aacf445d0c7b5646.
Report an issue: GitHub.