feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · AttributeError

Attribute error in self_identification processing.

Error message

Attribute error in self_identification processing.

What it means

Raised while constructing JobApplicationProfile when processing the self_identification section raises AttributeError (e.g. calling a method/attribute on None or a non-dict value). The constructor unpacks data['self_identification'] into SelfIdentification(**...) and converts any AttributeError into this opaque re-raise, chaining the original as __cause__. The real cause is in the logged message and the chained exception, not the message text.

Source

Thrown at src/resume_schemas/job_application_profile.py:95

        if not isinstance(data, dict):
            logger.error(f"YAML data must be a dictionary, received: {type(data)}")
            raise TypeError("YAML data must be a dictionary.")

        # Process self_identification
        try:
            logger.debug("Processing self_identification")
            self.self_identification = SelfIdentification(**data['self_identification'])
            logger.debug(f"self_identification processed: {self.self_identification}")
        except KeyError as e:
            logger.error(f"Required field {e} is missing in self_identification data.")
            raise KeyError(f"Required field {e} is missing in self_identification data.") from e
        except TypeError as e:
            logger.error(f"Error in self_identification data: {e}")
            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

View on GitHub (pinned to 79155b52fa)

Solutions

  1. Inspect the chained exception (e.__cause__) and the logger.error line to see the exact attribute that failed.
  2. Validate that data['self_identification'] is a dict and each nested field matches SelfIdentification's expected types before constructing the profile.
  3. Fix the source data (e.g. replace null self_identification with {}) or make nested constructors defensive with (value or {}).
  4. If nulls are legitimate, gate construction: only build the section when the key holds a mapping.

Example fix

# before
profile = JobApplicationProfile(**data)  # data['self_identification'] is None -> AttributeError

# after
if not isinstance(data.get('self_identification'), dict):
    data['self_identification'] = {}
profile = JobApplicationProfile(**data)
Defensive patterns

Strategy: validation

Validate before calling

si = data.get('self_identification')
assert si is None or isinstance(si, dict), 'self_identification must be a dict'

Type guard

def has_valid_self_identification(data: dict) -> bool:
    si = data.get('self_identification')
    return si is None or isinstance(si, dict)

Try / catch

try:
    profile = JobApplicationProfile(**data)
except AttributeError as e:
    log.error("self_identification attr failure: %r cause=%r", e, e.__cause__)

Prevention

When it happens

Trigger: Passing resume data where data['self_identification'] (or a nested field) is None/str instead of dict, so attribute access inside SelfIdentification's own __init__ (e.g. x.get, list ops) fails with AttributeError, which this handler re-wraps.

Common situations: YAML/JSON resume files where self_identification is null, empty string, or malformed; LLM-generated resume JSON with wrong types; upstream keys present but with scalar values where objects are expected.

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/a96ccfa9ca074853. Report an issue: GitHub.