feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · AttributeError
Attribute error in work_preferences processing.
Error message
Attribute error in work_preferences processing.
What it means
AttributeError wrapper from the work_preferences try block: an attribute access on a wrongly-typed value (None/str) inside WorkPreferences construction is caught and re-raised as this generic message. As with the sibling handlers, the specifics live in the chained exception and the logger.error output, not the static message.
Source
Thrown at src/resume_schemas/job_application_profile.py:131
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 e
except AttributeError as e:
logger.error(f"Attribute error in work_preferences processing: {e}")
raise AttributeError("Attribute error in work_preferences processing.") from e
except Exception as e:
logger.error(f"An unexpected error occurred while processing work_preferences: {e}")
raise RuntimeError("An unexpected error occurred while processing work_preferences.") from e
# Process availability
try:
logger.debug("Processing availability")
self.availability = Availability(**data['availability'])
logger.debug(f"Availability processed: {self.availability}")
except KeyError as e:
logger.error(f"Required field {e} is missing in availability data.")
raise KeyError(f"Required field {e} is missing in availability data.") from e
except TypeError as e:
logger.error(f"Error in availability data: {e}")
raise TypeError(f"Error in availability data: {e}") from e
except AttributeError as e:
logger.error(f"Attribute error in availability processing: {e}")
raise AttributeError("Attribute error in availability processing.") from eView on GitHub (pinned to 79155b52fa)
Solutions
- Read e.__cause__ or the logged line to locate the failing attribute.
- Type-check and normalize nested work_preferences values (None → {}) before building the profile.
- Add defaults in WorkPreferences' constructor for optional nested objects.
Example fix
# before
wp = data['work_preferences'] # {'desired_locations': None}
self.work_preferences = WorkPreferences(**wp)
# after
wp = {k: (v if isinstance(v, (dict, list, bool, int, str)) else {}) for k, v in (data.get('work_preferences') or {}).items()}
self.work_preferences = WorkPreferences(**wp) Defensive patterns
Strategy: validation
Validate before calling
wp = data.get('work_preferences') or {}
wp = {k: (v if v is not None else {}) for k, v in wp.items()} Type guard
def work_preferences_fields_valid(wp) -> bool:
return isinstance(wp, dict) and all(v is None or isinstance(v, (dict, list, str, bool, int)) for v in wp.values()) Try / catch
try:
profile = JobApplicationProfile(**data)
except AttributeError as e:
if 'work_preferences' in str(e):
log.error('attr cause: %r', e.__cause__) Prevention
- Fill None nested fields with defaults before constructing
- Maintain consistent producers of nested preference data
When it happens
Trigger: Nested work_preferences fields (e.g. a shift or location preference) that are None/scalar while the code calls dict methods like .get/.items on them.
Common situations: Sparse YAML where optional preference subsections are null; data from external scrapers with inconsistent types; refactors changing nested field structure.
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
- Attribute error in legal_authorization processing.
- Attribute error in availability processing.
- Attribute error in salary_expectations processing.
- Required field {e} is missing in work_preferences data.
- Error in work_preferences data: {e}
AI-assisted analysis of feder-cr/Jobs_Applier_AI_Agent_AIHawk@79155b52fa (2026-08-28).
Data as JSON: /api/errors/80306776e36b335e.
Report an issue: GitHub.