feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · TypeError

Error in self_identification data: {e}

Error message

Error in self_identification data: {e}

What it means

When building SelfIdentification(**data['self_identification']) raises TypeError (e.g. an unexpected keyword argument because the YAML has a key the dataclass doesn't accept, or the value is not a mapping), the constructor re-raises TypeError('Error in self_identification data: ...') with the cause chained.

Source

Thrown at src/resume_schemas/job_application_profile.py:92

        except Exception as e:
            logger.error(f"Unexpected error occurred while parsing the YAML file: {e}")
            raise RuntimeError("An unexpected error occurred while parsing the YAML file.") from e

        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

View on GitHub (pinned to 79155b52fa)

Solutions

  1. Read the chained TypeError message: it names the unexpected keyword argument or unpacking problem.
  2. Align YAML keys with the SelfIdentification dataclass fields exactly (remove extras, fix typos, rename to current schema).
  3. Ensure self_identification is a nested mapping, not a scalar or list.

Example fix

# before
self_identification:
  sex: 'Male'   # wrong/legacy key -> TypeError
# after
self_identification:
  gender: 'Male'  # matches the dataclass field
Defensive patterns

Strategy: type-guard

Validate before calling

import yaml
si = (yaml.safe_load(text) or {}).get('self_identification')
assert isinstance(si, dict), 'self_identification must be a mapping'
extra = set(si) - ALLOWED_FIELDS  # fields of SelfIdentification
assert not extra, f'unexpected keys: {extra}'

Type guard

def self_identification_valid(data: dict, allowed: set) -> bool:
    si = data.get('self_identification')
    return isinstance(si, dict) and set(si) <= allowed

Try / catch

try:
    profile = JobApplicationProfile(text)
except TypeError as e:
    if 'self_identification' in str(e):
        logger.error('Bad self_identification keys: %s', e.__cause__)
        raise ConfigError('Fix self_identification keys in resume YAML') from e
    raise

Prevention

When it happens

Trigger: self_identification in YAML contains keys that don't match SelfIdentification's fields, or data['self_identification'] is not a dict (a string/list), making the ** unpacking fail with TypeError.

Common situations: Typos or extra keys in the YAML section, schema drift after upgrading the library (renamed dataclass fields), or self_identification written as a scalar instead of a mapping.

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