feder-cr/Jobs_Applier_AI_Agent_AIHawk · error · KeyError
Required field {e} is missing in salary_expectations data.
Error message
Required field {e} is missing in salary_expectations data. What it means
KeyError raised from the salary_expectations block of JobApplicationProfile.__init__: the top-level 'salary_expectations' key is absent (dict indexing), or the SalaryExpectations constructor requires a field (e.g. 'currency' or 'amount') that the nested dict lacks and its KeyError propagates here. The missing key name is embedded in the message.
Source
Thrown at src/resume_schemas/job_application_profile.py:161
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 e
except Exception as e:
logger.error(f"An unexpected error occurred while processing availability: {e}")
raise RuntimeError("An unexpected error occurred while processing availability.") from e
# Process salary_expectations
try:
logger.debug("Processing salary_expectations")
self.salary_expectations = SalaryExpectations(**data['salary_expectations'])
logger.debug(f"salary_expectations processed: {self.salary_expectations}")
except KeyError as e:
logger.error(f"Required field {e} is missing in salary_expectations data.")
raise KeyError(f"Required field {e} is missing in salary_expectations data.") from e
except TypeError as e:
logger.error(f"Error in salary_expectations data: {e}")
raise TypeError(f"Error in salary_expectations data: {e}") from e
except AttributeError as e:
logger.error(f"Attribute error in salary_expectations processing: {e}")
raise AttributeError("Attribute error in salary_expectations processing.") from e
except Exception as e:
logger.error(f"An unexpected error occurred while processing salary_expectations: {e}")
raise RuntimeError("An unexpected error occurred while processing salary_expectations.") from e
logger.debug("JobApplicationProfile initialization completed successfully.")
def __str__(self):
logger.debug("Generating string representation of JobApplicationProfile")
def format_dataclass(obj):
return "\n".join(f"{field.name}: {getattr(obj, field.name)}" for field in obj.__dataclass_fields__.values())
View on GitHub (pinned to 79155b52fa)
Solutions
- Add the missing key named in the message (top-level key or nested field).
- Default the section if optional: data.setdefault('salary_expectations', {}) before construction.
- Inspect SalaryExpectations.__init__ to see mandatory fields and fill them from source data.
Example fix
# before
self.salary_expectations = SalaryExpectations(**data['salary_expectations'])
# after
se = data.get('salary_expectations') or {}
self.salary_expectations = SalaryExpectations(**se) Defensive patterns
Strategy: validation
Validate before calling
data.setdefault('salary_expectations', {}) Type guard
def has_salary_expectations(data: dict) -> bool:
return isinstance(data.get('salary_expectations'), dict) Try / catch
try:
profile = JobApplicationProfile(**data)
except KeyError as e:
if 'salary_expectations' in str(e):
data.setdefault('salary_expectations', {})
profile = JobApplicationProfile(**data) Prevention
- Default optional salary section to {}
- Ensure required nested salary fields are populated when the section is present
When it happens
Trigger: JobApplicationProfile(**data) with no 'salary_expectations' in data, or a salary dict missing a field SalaryExpectations declares as required.
Common situations: Candidates omitting salary expectations from resumes; pipelines dropping empty sections; schema changes promoting optional salary fields to required.
Understand the failure class
Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.
Related errors
- Required field {e} is missing in legal_authorization data.
- Required field {e} is missing in work_preferences data.
- Required field {e} is missing in availability data.
- Error in salary_expectations data: {e}
- Attribute error in salary_expectations processing.
AI-assisted analysis of feder-cr/Jobs_Applier_AI_Agent_AIHawk@79155b52fa (2026-08-28).
Data as JSON: /api/errors/967743e4a48f0b5e.
Report an issue: GitHub.