feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · KeyError

Required field {e} is missing in self_identification data.

Error message

Required field {e} is missing in self_identification data.

What it means

While constructing SelfIdentification from data['self_identification'], a missing required mapping key raises KeyError (data['self_identification'] itself absent, or a nested required key). The constructor catches it and re-raises KeyError with the message naming the missing field.

Source

Thrown at src/resume_schemas/job_application_profile.py:89

        except yaml.YAMLError as e:
            logger.error(f"Error parsing YAML file: {e}")
            raise ValueError("Error parsing YAML file.") from e
        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

View on GitHub (pinned to 79155b52fa)

Solutions

  1. Add the missing section/key reported in the message to your YAML (start from the project's example resume YAML).
  2. If fields were renamed by a schema change, migrate your YAML to the current field names.
  3. Validate required keys before constructing JobApplicationProfile.

Example fix

# before
# resume.yaml without self_identification
# after
self_identification:
  gender: 'Prefer not to say'
  pronouns: 'Prefer not to say'
  veteran: 'No'
  disability: 'No'
  ethnicity: 'Prefer not to say'
Defensive patterns

Strategy: validation

Validate before calling

import yaml
data = yaml.safe_load(text) or {}
required = ['self_identification', 'personal_info']  # adjust to schema
missing = [k for k in required if k not in data]
assert not missing, f'missing sections: {missing}'

Type guard

def has_required_sections(text: str, required=('self_identification',)) -> bool:
    import yaml
    data = yaml.safe_load(text)
    return isinstance(data, dict) and all(k in data for k in required)

Try / catch

try:
    profile = JobApplicationProfile(text)
except KeyError as e:
    if 'self_identification' in str(e):
        raise ConfigError('Add self_identification to resume YAML') from e
    raise

Prevention

When it happens

Trigger: The parsed YAML dict lacks the self_identification key (or one of its required sub-fields), e.g. the resume YAML was trimmed or a field was renamed.

Common situations: Incomplete resume templates, schema drift after library updates renaming fields, or hand-editing that deleted a block.

Related errors


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