feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · AttributeError

Attribute error in legal_authorization processing.

Error message

Attribute error in legal_authorization processing.

What it means

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.

Source

Thrown at src/resume_schemas/job_application_profile.py:113

            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 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

View on GitHub (pinned to 79155b52fa)

Solutions

  1. Check e.__cause__ / server logs for the exact attribute that failed.
  2. Type-check nested legal_authorization fields (dict vs None vs str) before constructing the profile.
  3. Normalize the data (fill None with {} / defaults) or make LegalInformation's constructor defensive.

Example fix

# before
la = data['legal_authorization']  # {'work_permit': None}
self.legal_authorization = LegalAuthorization(**la)  # internal .get on None

# after
la = {k: (v if v is not None else {}) for k, v in data['legal_authorization'].items()}
self.legal_authorization = LegalAuthorization(**la)
Defensive patterns

Strategy: validation

Validate before calling

la = data.get('legal_authorization') or {}
la = {k: (v if v is not None else {}) for k, v in la.items()}

Type guard

def legal_authorization_fields_valid(la) -> bool:
    return isinstance(la, dict) and all(v is None or isinstance(v, (dict, list, str, bool, int)) for v in la.values())

Try / catch

try:
    profile = JobApplicationProfile(**data)
except AttributeError as e:
    if 'legal_authorization' in str(e):
        normalize_nulls(data['legal_authorization'])

Prevention

When it happens

Trigger: Nested fields inside legal_authorization being None or a string while LegalAuthorization's constructor calls dict-style methods or attribute access on them.

Common situations: Sparse resume data where optional legal-authorization fields are null; inconsistent producers of the resume JSON; refactors that changed nested field types.

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


AI-assisted analysis of feder-cr/Jobs_Applier_AI_Agent_AIHawk@79155b52fa (2026-08-28). Data as JSON: /api/errors/70885e2541ed9fb2. Report an issue: GitHub.